-
Notifications
You must be signed in to change notification settings - Fork 28
248 lines (206 loc) · 6.94 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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
name: CI
on:
pull_request:
push:
branches: main
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
generate-matrix:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- id: prep
run: |
echo "matrix=$(./.github/bin/generate-matrix)" >>"$GITHUB_OUTPUT"
echo "matrix-ext=$(./.github/bin/generate-matrix external)" >>"$GITHUB_OUTPUT"
outputs:
matrix: ${{ steps.prep.outputs.matrix }}
matrix-ext: ${{ steps.prep.outputs.matrix-ext }}
test:
runs-on: ubuntu-latest
needs: generate-matrix
strategy:
matrix: ${{ fromJSON(needs.generate-matrix.outputs.matrix) }}
fail-fast: false
steps:
- uses: actions/checkout@v4
- id: prep
name: Prepare
run: |
image=restyled/restyler-${{ matrix.restyler }}:${{ github.sha }}
echo "image=$image" >> "$GITHUB_OUTPUT"
- name: Lint
uses: hadolint/hadolint-action@v3.1.0
with:
dockerfile: ${{ matrix.restyler }}/Dockerfile
failure-threshold: error
- id: buildx
name: Setup buildx
uses: docker/setup-buildx-action@v3
- name: Restore cache
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-${{ matrix.restyler }}-image-${{ github.sha }}
restore-keys: |
${{ runner.os }}-${{ matrix.restyler }}-image-
- name: Registry login
if: ${{ github.ref == 'refs/heads/main' }}
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Build
if: ${{ github.ref != 'refs/heads/main' }}
uses: docker/build-push-action@v5
with:
builder: ${{ steps.buildx.outputs.name }}
context: ${{ matrix.restyler }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new
outputs: type=docker
tags: ${{ steps.prep.outputs.image }}
- name: Build and Push
if: ${{ github.ref == 'refs/heads/main' }}
uses: docker/build-push-action@v5
with:
builder: ${{ steps.buildx.outputs.name }}
context: ${{ matrix.restyler }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new
push: true
tags: ${{ steps.prep.outputs.image }}
- name: Cache cleanup
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
- name: Container credentials
if: ${{ github.ref == 'refs/heads/main' }}
run: |
mkdir -p ~/work/_temp/_github_home/.docker
cp ~/.docker/config.json ~/work/_temp/_github_home/.docker/config.json
- name: Test
if: ${{ github.ref != 'refs/heads/main' }}
uses: restyled-io/sdk@main
with:
command: >-
restylers
--sha ${{ github.sha }}
--no-build
--write restyler.yaml
${{ matrix.restyler }}
${{ matrix.overrides }}
- name: Test and Push
if: ${{ github.ref == 'refs/heads/main' }}
uses: restyled-io/sdk@main
with:
command: >-
restylers
--sha ${{ github.sha }}
--no-build
--push
--write restyler.yaml
${{ matrix.restyler }}
${{ matrix.overrides }}
- if: ${{ github.ref == 'refs/heads/main' }}
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.restyler }}
path: restyler.yaml
test-external:
runs-on: ubuntu-latest
needs: generate-matrix
strategy:
matrix: ${{ fromJSON(needs.generate-matrix.outputs.matrix-ext) }}
fail-fast: false
steps:
- uses: actions/checkout@v4
- name: Test
uses: restyled-io/sdk@main
with:
command: >-
restylers
--sha ${{ github.sha }}
--no-build
--write restyler.yaml
${{ matrix.restyler }}
- if: ${{ github.ref == 'refs/heads/main' }}
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.restyler }}
path: restyler.yaml
# See https://github.com/orgs/community/discussions/60792
status:
needs: [test, test-external]
if: ${{ failure() || cancelled() }}
runs-on: ubuntu-latest
steps:
- run: |
echo "Some Restylers have failed or been cancelled"
exit 1
promote:
if: ${{ github.ref == 'refs/heads/main' }}
needs: [test, test-external]
runs-on: ubuntu-latest
env:
AWS_ACCESS_KEY_ID: ${{ secrets.aws_access_key_id }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.aws_secret_access_key }}
AWS_DEFAULT_REGION: us-east-1
steps:
- uses: actions/download-artifact@v4
- name: Build manifest
run: |
cat **/*.yaml > restylers.yaml
- name: Promote to sha tag
uses: restyled-io/sdk@main
with:
command: >-
promote --yes --no-test --file restylers.yaml ${{ github.sha }}
release:
if: ${{ github.ref == 'refs/heads/main' }}
needs: [promote]
runs-on: ubuntu-latest
env:
AWS_ACCESS_KEY_ID: ${{ secrets.aws_access_key_id }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.aws_secret_access_key }}
AWS_DEFAULT_REGION: us-east-1
steps:
- uses: actions/checkout@v4
- id: tag
name: Tag
uses: mathieudutour/github-tag-action@v6.2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Release
uses: actions/create-release@v1
with:
tag_name: ${{ steps.tag.outputs.new_tag }}
release_name: Release ${{ steps.tag.outputs.new_tag }}
body: ${{ steps.tag.outputs.changelog }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Promote to version tag
uses: restyled-io/sdk@main
with:
command: >-
promote --yes --no-test ${{ github.sha }} ${{ steps.tag.outputs.new_tag }}
- name: Promote to dev
uses: restyled-io/sdk@main
with:
command: >-
promote --yes --no-test ${{ github.sha }} dev
- name: Notify
uses: zulip/github-actions-zulip/send-message@v1.0.2
with:
api-key: ${{ secrets.ZULIP_API_KEY }}
email: ${{ secrets.ZULIP_EMAIL }}
organization-url: ${{ secrets.ZULIP_ORGANIZATION_URL }}
to: 'changelog'
type: 'stream'
topic: 'Restylers Releases'
content: |
Restylers [${{ steps.tag.outputs.new_tag }}](https://github.com/restyled-io/restylers/releases/tag/${{ steps.tag.outputs.new_tag }}) released to `dev` channel
${{ steps.tag.outputs.changelog }}
Commit: ${{ github.sha }}