forked from naskio/docker-strapi
-
Notifications
You must be signed in to change notification settings - Fork 5
256 lines (219 loc) · 7.47 KB
/
publish-docker-images.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
249
250
251
252
253
254
255
256
name: Publish Docker Image
on:
push:
paths:
- 'release-versions/*'
jobs:
tags:
name: Get Tags
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.vars.outputs.TAG }}
latest: ${{ steps.vars.outputs.LATEST }}
steps:
- name: Get Current Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get Changed Release Files
id: changed-files
uses: tj-actions/changed-files@v45
with:
files: release-versions/**
- name: Get Tag and Latest
id: vars
run: |
if echo "${{ steps.changed-files.outputs.modified_files }}" | grep -q 'strapi-v5-latest.txt'; then
echo "TAG=$(cat release-versions/strapi-v5-latest.txt)" >> "$GITHUB_OUTPUT"
echo "LATEST=latest" >> "$GITHUB_OUTPUT"
else
echo "TAG=$(cat release-versions/strapi-v4-latest.txt)" >> "$GITHUB_OUTPUT"
echo "LATEST=latest-v4" >> "$GITHUB_OUTPUT"
fi
test-image:
name: Test Debian Image
needs: [tags]
runs-on: ubuntu-latest
env:
TAG: ${{ needs.tags.outputs.tag }}
OLDV4: 4.15.0
OLDV5: 5.0.0
steps:
- name: Get Current Repository
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build Latest Image and Export to Docker
uses: docker/build-push-action@v6
with:
load: true
context: ./images/strapi-debian
build-args: |
STRAPI_VERSION=${{ env.TAG }}
NODE_VERSION=18
NODE=node
GITHUB_ACTIONS=1
tags: ${{ secrets.DOCKER_USERNAME }}/strapi:lat
- name: Run Latest Image
timeout-minutes: 10
run: |
docker run --rm ${{ secrets.DOCKER_USERNAME }}/strapi:lat
- name: Create Temp V4 and V5 Volumes
run: |
mkdir ${{ runner.temp }}/strapiv4 ${{ runner.temp }}/strapiv5
- name: Build Old V4 Image and Export to Docker
uses: docker/build-push-action@v6
with:
load: true
context: ./images/strapi-debian
build-args: |
STRAPI_VERSION=${{ env.OLDV4 }}
NODE_VERSION=18
NODE=node
GITHUB_ACTIONS=1
tags: ${{ secrets.DOCKER_USERNAME }}/strapi:oldv4
- name: Init Old V4 Image
timeout-minutes: 10
run: |
docker run --rm -v ${{ runner.temp }}/strapiv4:/srv/app ${{ secrets.DOCKER_USERNAME }}/strapi:oldv4
- name: Test Old V4 Image Upgrade
timeout-minutes: 10
run: |
docker run --rm -v ${{ runner.temp }}/strapiv4:/srv/app ${{ secrets.DOCKER_USERNAME }}/strapi:lat
- name: Build Old V5 Image and Export to Docker
uses: docker/build-push-action@v6
if: startsWith(env.TAG, '5')
with:
load: true
context: ./images/strapi-debian
build-args: |
STRAPI_VERSION=${{ env.OLDV5 }}
NODE_VERSION=18
NODE=node
GITHUB_ACTIONS=1
tags: ${{ secrets.DOCKER_USERNAME }}/strapi:oldv5
- name: Init Old V5 Image
if: startsWith(env.TAG, '5')
timeout-minutes: 10
run: |
docker run --rm -v ${{ runner.temp }}/strapiv5:/srv/app ${{ secrets.DOCKER_USERNAME }}/strapi:oldv5
- name: Test Old V5 Image Upgrade
if: startsWith(env.TAG, '5')
timeout-minutes: 10
run: |
docker run --rm -v ${{ runner.temp }}/strapiv5:/srv/app ${{ secrets.DOCKER_USERNAME }}/strapi:lat
build-and-push:
name: Build and Push Images
needs: [tags, test-image]
runs-on: ubuntu-latest
env:
TAG: ${{ needs.tags.outputs.tag }}
LATEST: ${{ needs.tags.outputs.latest }}
steps:
- name: Get Current Repository
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build (default => debian)
uses: docker/build-push-action@v6
with:
context: ./images/strapi-debian
platforms: linux/amd64
build-args: |
STRAPI_VERSION=${{ env.TAG }}
NODE_VERSION=18
NODE=node
push: true
tags: |
${{ secrets.DOCKER_USERNAME }}/strapi:${{ env.TAG }}
${{ secrets.DOCKER_USERNAME }}/strapi:${{ env.LATEST }}
- name: Build (alpine)
uses: docker/build-push-action@v6
with:
context: ./images/strapi-alpine
platforms: linux/amd64
build-args: |
STRAPI_VERSION=${{ env.TAG }}
NODE_VERSION=18
NODE=node
push: true
tags: |
${{ secrets.DOCKER_USERNAME }}/strapi:${{ env.TAG }}-alpine
${{ secrets.DOCKER_USERNAME }}/strapi:${{ env.LATEST }}-alpine
- name: Build (default => debian arm64)
uses: docker/build-push-action@v6
with:
context: ./images/strapi-debian
platforms: linux/arm64
build-args: |
STRAPI_VERSION=${{ env.TAG }}
NODE_VERSION=18
NODE=arm64v8/node
push: true
tags: |
${{ secrets.DOCKER_USERNAME }}/strapi:${{ env.TAG }}-arm64
${{ secrets.DOCKER_USERNAME }}/strapi:${{ env.LATEST }}-arm64
- name: Build (alpine arm64)
uses: docker/build-push-action@v6
with:
context: ./images/strapi-alpine
platforms: linux/arm64
build-args: |
STRAPI_VERSION=${{ env.TAG }}
NODE_VERSION=18
NODE=arm64v8/node
push: true
tags: |
${{ secrets.DOCKER_USERNAME }}/strapi:${{ env.TAG }}-alpine-arm64
${{ secrets.DOCKER_USERNAME }}/strapi:${{ env.LATEST }}-alpine-arm64
release:
name: Release
needs: [tags, build-and-push]
runs-on: ubuntu-latest
env:
TAG: ${{ needs.tags.outputs.tag }}
permissions:
contents: write
steps:
- name: Get Current Repository
uses: actions/checkout@v4
- name: Create Latest Release in GitHub
id: create_v5_release
if: startsWith(env.TAG, '5')
uses: softprops/action-gh-release@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag_name: v${{ env.TAG }}
prerelease: false
draft: false
generate_release_notes: true
name: Release ${{ env.TAG }}
body: Strapi v${{ env.TAG }}
make_latest: true
- name: Create Release in GitHub
id: create_v4_release
if: startsWith(env.TAG, '4')
uses: softprops/action-gh-release@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag_name: v${{ env.TAG }}
prerelease: false
draft: false
generate_release_notes: true
name: Release ${{ env.TAG }}
body: Strapi v${{ env.TAG }}
make_latest: false