-
Notifications
You must be signed in to change notification settings - Fork 1
141 lines (116 loc) · 4.05 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
name: CI
on:
push:
branches:
- main
pull_request:
permissions: read-all
env:
TEST_TAG: user/api:test
jobs:
setup:
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1
with:
egress-policy: audit
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Setup bun
uses: oven-sh/setup-bun@123c6c4e2fea3eb7bffaa91a85eb6b3d505bf7af # v2
with:
bun-version: 1.1.18
- name: Setup go
uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
with:
go-version: 1.22.2
- name: Setup bun cache
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
id: bun-cache
with:
path: |
./node_modules
key: ${{ runner.os }}-bun-${{ hashFiles('./bun.lockb') }}
- name: bun install
if: steps.bun-cache.outputs.cache-hit != 'true'
run: |
bun i
- name: Setup generate cache
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
id: generate-cache
with:
path: |
./public/style.css
./internal/template/**/*_templ.go
key: ${{ runner.os }}-generate-${{ hashFiles('./internal/template/**/*.templ') }}
- name: Generate
if: steps.generate-cache.outputs.cache-hit != 'true'
run: |
mkdir -p bin/
go install github.com/a-h/templ/cmd/[email protected]
templ generate
./node_modules/.bin/tailwindcss -i ./style.css -o ./public/style.css
test:
needs: [setup]
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1
with:
egress-policy: audit
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Setup go
uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
with:
go-version: 1.22.2
- name: Restore generate cache
uses: actions/cache/restore@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
path: |
./public/style.css
./internal/template/**/*_templ.go
key: ${{ runner.os }}-generate-${{ hashFiles('./internal/template/**/*.templ') }}
- name: Test
run: |
go test -v ./...
build:
needs: [setup]
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1
with:
egress-policy: audit
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Setup go
uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
with:
go-version: 1.22.2
- name: Restore generate cache
uses: actions/cache/restore@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
path: |
./public/style.css
./internal/template/**/*_templ.go
key: ${{ runner.os }}-generate-${{ hashFiles('./internal/template/**/*.templ') }}
- name: Dry Build API
run: |
go build -o ./tmp/main ./cmd/api/main.go
docker:
needs: [test, setup, build]
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1
with:
egress-policy: audit
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Set up Docker buildx
uses: docker/setup-buildx-action@4fd812986e6c8c2a69e18311145f9371337f27d4 # v3.4.0
- name: Dry Build API
uses: docker/build-push-action@1a162644f9a7e87d8f4b053101d1d9a712edc18c # v6.3.0
with:
context: .
load: true
file: ./Dockerfile
tags: ${{ env.TEST_TAG }}