Repository navigation
211 lines (195 loc) · 6.62 KB
/
Copy pathci-cd.yml
File metadata and controls
211 lines (195 loc) · 6.62 KB
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
name: CI/CD
on:
push:
branches: [master]
pull_request:
workflow_dispatch:
schedule:
- cron: "0 0 * * 0"
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
# Never interrupt a release between publishing base and derived images.
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
checks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Verify generated images match templates
run: |
docker run --rm --user "$(id -u):$(id -g)" -v "$PWD:/app" fireworkweb/fwd:v1.0 fwd template
git diff --exit-code
build-test:
needs: checks
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
version: ["8.2", "8.3", "8.4", "8.5"]
distro: ["", "-debian"]
type: ["", "-prod"]
exclude:
- {version: "8.2", distro: "-debian"}
- {version: "8.3", distro: "-debian"}
env:
BASE: ${{ matrix.version }}${{ matrix.distro }}${{ matrix.type }}
NGINX: ${{ matrix.version }}${{ matrix.distro }}-nginx${{ matrix.type }}
NODE: ${{ matrix.version }}-node
steps:
- uses: actions/checkout@v7
# The docker driver lets derived images use the base built in this job.
# Tests are native amd64; QEMU is only needed for multi-arch publishing.
- uses: docker/setup-buildx-action@v4
with:
driver: docker
- name: Build base image
uses: docker/build-push-action@v7
with:
context: ${{ env.BASE }}
load: true
tags: kooldev/php:${{ env.BASE }}
- name: Test base image
run: bash scripts/test-image.sh "$BASE"
- name: Build nginx image
uses: docker/build-push-action@v7
with:
context: ${{ env.NGINX }}
load: true
tags: kooldev/php:${{ env.NGINX }}
- name: Test nginx image
run: bash scripts/test-image.sh "$NGINX"
- name: Build node image
if: matrix.distro == '' && matrix.type == ''
uses: docker/build-push-action@v7
with:
context: ${{ env.NODE }}
load: true
tags: kooldev/php:${{ env.NODE }}
- name: Test node image
if: matrix.distro == '' && matrix.type == ''
run: bash scripts/test-image.sh "$NODE"
# Multi-arch builds use the isolated docker-container driver. Publish all
# base images first so nginx/node builds can pull them from Docker Hub.
push-base:
needs: build-test
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/master' && github.repository == 'kool-dev/docker-php'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
version: ["8.2", "8.3", "8.4", "8.5"]
distro: ["", "-debian"]
type: ["", "-prod"]
exclude:
- {version: "8.2", distro: "-debian"}
- {version: "8.3", distro: "-debian"}
env:
TAG: ${{ matrix.version }}${{ matrix.distro }}${{ matrix.type }}
steps:
- uses: actions/checkout@v7
- uses: docker/setup-qemu-action@v4
with:
platforms: arm64
- uses: docker/setup-buildx-action@v4
- uses: docker/login-action@v4
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Publish base image
uses: docker/build-push-action@v7
with:
context: ${{ env.TAG }}
push: true
platforms: linux/amd64,linux/arm64
tags: kooldev/php:${{ env.TAG }}
push-nginx:
needs: push-base
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/master' && github.repository == 'kool-dev/docker-php'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
version: ["8.2", "8.3", "8.4", "8.5"]
distro: ["", "-debian"]
type: ["", "-prod"]
exclude:
- {version: "8.2", distro: "-debian"}
- {version: "8.3", distro: "-debian"}
env:
TAG: ${{ matrix.version }}${{ matrix.distro }}-nginx${{ matrix.type }}
steps:
- uses: actions/checkout@v7
- uses: docker/setup-qemu-action@v4
with:
platforms: arm64
- uses: docker/setup-buildx-action@v4
- uses: docker/login-action@v4
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Publish nginx image
uses: docker/build-push-action@v7
with:
context: ${{ env.TAG }}
push: true
platforms: linux/amd64,linux/arm64
tags: kooldev/php:${{ env.TAG }}
push-node:
needs: push-base
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/master' && github.repository == 'kool-dev/docker-php'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
version: ["8.2", "8.3", "8.4", "8.5"]
env:
TAG: ${{ matrix.version }}-node
steps:
- uses: actions/checkout@v7
- uses: docker/setup-qemu-action@v4
with:
platforms: arm64
- uses: docker/setup-buildx-action@v4
- uses: docker/login-action@v4
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Publish node image
uses: docker/build-push-action@v7
with:
context: ${{ env.TAG }}
push: true
platforms: linux/amd64,linux/arm64
tags: kooldev/php:${{ env.TAG }}
trigger-downstream:
needs: [push-nginx, push-node]
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/master' && github.repository == 'kool-dev/docker-php'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
repo:
- kool-dev/docker-wordpress
- kool-dev/docker-php-sqlsrv
- kool-dev/docker-php-swoole
- kool-dev/docker-phpqa
steps:
- name: Check downstream credentials
id: credentials
env:
DISPATCH_TOKEN: ${{ secrets.DISPATCH_TOKEN }}
run: |
if [ -n "$DISPATCH_TOKEN" ]; then
echo "available=true" >> "$GITHUB_OUTPUT"
else
echo "::warning::Downstream builds skipped: configure DISPATCH_TOKEN with access to the downstream repositories."
fi
- name: Trigger ${{ matrix.repo }}
if: steps.credentials.outputs.available == 'true'
uses: peter-evans/repository-dispatch@v4
with:
token: ${{ secrets.DISPATCH_TOKEN }}
repository: ${{ matrix.repo }}
event-type: docker-php-updated