Skip to content

Commit 3c892f9

Browse files
committed
update ci-cd fix sequence issue
1 parent e0edb16 commit 3c892f9

File tree

1 file changed

+117
-35
lines changed

1 file changed

+117
-35
lines changed

.github/workflows/ci-cd.yml

Lines changed: 117 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ on:
77
- cron: "0 0 * * 0"
88

99
jobs:
10-
build:
10+
# ===========================================
11+
# Alpine Base Images (Phase 1)
12+
# ===========================================
13+
build-alpine-base:
1114
runs-on: ubuntu-latest
1215

1316
strategy:
@@ -53,12 +56,10 @@ jobs:
5356
- name: Tests - Dockerize
5457
run: |
5558
docker run kooldev/php:${{ matrix.version }}${{ matrix.type }} dockerize --version
56-
# Test dockerize template rendering
5759
docker run kooldev/php:${{ matrix.version }}${{ matrix.type }} sh -c 'echo "{{ .Env.TEST_VAR }}" > /tmp/test.tmpl && TEST_VAR=hello dockerize -template /tmp/test.tmpl:/tmp/test.out && cat /tmp/test.out | grep hello'
5860
5961
- name: Tests - PHP Extensions
6062
run: |
61-
# Core extensions that must be present in all images
6263
docker run kooldev/php:${{ matrix.version }}${{ matrix.type }} php -m | grep -i bcmath
6364
docker run kooldev/php:${{ matrix.version }}${{ matrix.type }} php -m | grep -i gd
6465
docker run kooldev/php:${{ matrix.version }}${{ matrix.type }} php -m | grep -i intl
@@ -72,17 +73,13 @@ jobs:
7273
- name: Tests - Production Checks
7374
if: matrix.type == '-prod'
7475
run: |
75-
# OPcache must be enabled in production
7676
docker run kooldev/php:${{ matrix.version }}${{ matrix.type }} php -m | grep -i "Zend OPcache"
77-
# Xdebug must NOT be present in production (even when ENABLE_XDEBUG=true)
7877
docker run -e ENABLE_XDEBUG=true kooldev/php:${{ matrix.version }}${{ matrix.type }} php -m | grep -i xdebug && exit 1 || echo "OK: xdebug not in prod"
7978
8079
- name: Tests - Development Checks
8180
if: matrix.type == ''
8281
run: |
83-
# pcov should be available in dev
8482
docker run kooldev/php:${{ matrix.version }}${{ matrix.type }} php -m | grep -i pcov
85-
# xdebug should be available when enabled
8683
docker run -e ENABLE_XDEBUG=true kooldev/php:${{ matrix.version }}${{ matrix.type }} php -m | grep -i xdebug
8784
8885
- name: Build and push
@@ -94,28 +91,42 @@ jobs:
9491
push: true
9592
tags: kooldev/php:${{ matrix.version }}${{ matrix.type }}
9693

94+
# ===========================================
95+
# Alpine Nginx Images (Phase 2 - depends on base)
96+
# ===========================================
97+
build-alpine-nginx:
98+
runs-on: ubuntu-latest
99+
needs: build-alpine-base
100+
101+
strategy:
102+
matrix:
103+
version: ["8.1", "8.2", "8.3", "8.4"]
104+
type: ["", "-prod"]
105+
106+
steps:
107+
- name: Checkout code
108+
uses: actions/checkout@v5.0.0
109+
110+
- name: Setup QEMU
111+
uses: docker/setup-qemu-action@v3
112+
113+
- name: Setup Docker Buildx
114+
uses: docker/setup-buildx-action@v3
115+
116+
- name: Login to DockerHub
117+
uses: docker/login-action@v3
118+
if: github.ref == 'refs/heads/master' && github.repository == 'kool-dev/docker-php'
119+
with:
120+
username: ${{ secrets.DOCKER_USERNAME }}
121+
password: ${{ secrets.DOCKER_PASSWORD }}
122+
97123
- name: Build and export to Docker (nginx)
98124
uses: docker/build-push-action@v6
99125
with:
100126
context: ${{ matrix.version }}-nginx${{ matrix.type }}
101127
load: true
102128
tags: kooldev/php:${{ matrix.version }}-nginx${{ matrix.type }}
103129

104-
- name: Build and export to Docker (Node)
105-
uses: docker/build-push-action@v6
106-
if: matrix.type == ''
107-
with:
108-
context: ${{ matrix.version }}-node${{ matrix.type }}
109-
load: true
110-
tags: kooldev/php:${{ matrix.version }}-node${{ matrix.type }}
111-
112-
- name: Tests (Node)
113-
if: matrix.type == ''
114-
run: |
115-
docker run kooldev/php:${{ matrix.version }}-node${{ matrix.type }} node -v
116-
docker run kooldev/php:${{ matrix.version }}-node${{ matrix.type }} npm -v
117-
docker run kooldev/php:${{ matrix.version }}-node${{ matrix.type }} yarn -v
118-
119130
- name: Tests (nginx) - Basic
120131
run: |
121132
docker run kooldev/php:${{ matrix.version }}-nginx${{ matrix.type }} php -v
@@ -133,7 +144,6 @@ jobs:
133144
- name: Tests (nginx) - Dockerize
134145
run: |
135146
docker run kooldev/php:${{ matrix.version }}-nginx${{ matrix.type }} dockerize --version
136-
# Test dockerize template rendering
137147
docker run kooldev/php:${{ matrix.version }}-nginx${{ matrix.type }} sh -c 'echo "{{ .Env.TEST_VAR }}" > /tmp/test.tmpl && TEST_VAR=hello dockerize -template /tmp/test.tmpl:/tmp/test.out && cat /tmp/test.out | grep hello'
138148
139149
- name: Tests (nginx) - PHP Extensions
@@ -169,21 +179,65 @@ jobs:
169179
push: true
170180
tags: kooldev/php:${{ matrix.version }}-nginx${{ matrix.type }}
171181

182+
# ===========================================
183+
# Alpine Node Images (Phase 2 - depends on base)
184+
# ===========================================
185+
build-alpine-node:
186+
runs-on: ubuntu-latest
187+
needs: build-alpine-base
188+
189+
strategy:
190+
matrix:
191+
version: ["8.1", "8.2", "8.3", "8.4"]
192+
193+
steps:
194+
- name: Checkout code
195+
uses: actions/checkout@v5.0.0
196+
197+
- name: Setup QEMU
198+
uses: docker/setup-qemu-action@v3
199+
200+
- name: Setup Docker Buildx
201+
uses: docker/setup-buildx-action@v3
202+
203+
- name: Login to DockerHub
204+
uses: docker/login-action@v3
205+
if: github.ref == 'refs/heads/master' && github.repository == 'kool-dev/docker-php'
206+
with:
207+
username: ${{ secrets.DOCKER_USERNAME }}
208+
password: ${{ secrets.DOCKER_PASSWORD }}
209+
210+
- name: Build and export to Docker (Node)
211+
uses: docker/build-push-action@v6
212+
with:
213+
context: ${{ matrix.version }}-node
214+
load: true
215+
tags: kooldev/php:${{ matrix.version }}-node
216+
217+
- name: Tests (Node)
218+
run: |
219+
docker run kooldev/php:${{ matrix.version }}-node node -v
220+
docker run kooldev/php:${{ matrix.version }}-node npm -v
221+
docker run kooldev/php:${{ matrix.version }}-node yarn -v
222+
172223
- name: Build and push (Node)
173224
uses: docker/build-push-action@v6
174-
if: github.ref == 'refs/heads/master' && github.repository == 'kool-dev/docker-php' && matrix.type == ''
225+
if: github.ref == 'refs/heads/master' && github.repository == 'kool-dev/docker-php'
175226
with:
176-
context: ${{ matrix.version }}-node${{ matrix.type }}
227+
context: ${{ matrix.version }}-node
177228
platforms: linux/amd64,linux/arm64
178229
push: true
179-
tags: kooldev/php:${{ matrix.version }}-node${{ matrix.type }}
230+
tags: kooldev/php:${{ matrix.version }}-node
180231

181-
build-debian:
232+
# ===========================================
233+
# Debian Base Images (Phase 1)
234+
# ===========================================
235+
build-debian-base:
182236
runs-on: ubuntu-latest
183237

184238
strategy:
185239
matrix:
186-
type: ['', '-prod']
240+
type: ["", "-prod"]
187241

188242
steps:
189243
- name: Checkout code
@@ -202,7 +256,7 @@ jobs:
202256
username: ${{ secrets.DOCKER_USERNAME }}
203257
password: ${{ secrets.DOCKER_PASSWORD }}
204258

205-
- name: Build and export to Docker (Debian)
259+
- name: Build and export to Docker (Debian base)
206260
uses: docker/build-push-action@v6
207261
with:
208262
context: 8.4-debian${{ matrix.type }}
@@ -223,18 +277,15 @@ jobs:
223277
- name: Tests (Debian) - Dockerize
224278
run: |
225279
docker run kooldev/php:8.4-debian${{ matrix.type }} dockerize --version
226-
# Test dockerize template rendering with bash
227280
docker run kooldev/php:8.4-debian${{ matrix.type }} bash -c 'echo "{{ .Env.TEST_VAR }}" > /tmp/test.tmpl && TEST_VAR=hello dockerize -template /tmp/test.tmpl:/tmp/test.out && cat /tmp/test.out | grep hello'
228281
229282
- name: Tests (Debian) - Gosu user switching
230283
run: |
231284
docker run kooldev/php:8.4-debian${{ matrix.type }} gosu --version
232-
# Verify gosu works for user switching - should be uid=1000 when ASUSER=1000
233285
docker run -e ASUSER=1000 kooldev/php:8.4-debian${{ matrix.type }} id | grep "uid=1000"
234286
235287
- name: Tests (Debian) - PHP Extensions
236288
run: |
237-
# Same extensions as Alpine for consistency
238289
docker run kooldev/php:8.4-debian${{ matrix.type }} php -m | grep -i bcmath
239290
docker run kooldev/php:8.4-debian${{ matrix.type }} php -m | grep -i gd
240291
docker run kooldev/php:8.4-debian${{ matrix.type }} php -m | grep -i intl
@@ -257,7 +308,7 @@ jobs:
257308
docker run kooldev/php:8.4-debian${{ matrix.type }} php -m | grep -i pcov
258309
docker run -e ENABLE_XDEBUG=true kooldev/php:8.4-debian${{ matrix.type }} php -m | grep -i xdebug
259310
260-
- name: Build and push (Debian)
311+
- name: Build and push (Debian base)
261312
uses: docker/build-push-action@v6
262313
if: github.ref == 'refs/heads/master' && github.repository == 'kool-dev/docker-php'
263314
with:
@@ -266,6 +317,34 @@ jobs:
266317
push: true
267318
tags: kooldev/php:8.4-debian${{ matrix.type }}
268319

320+
# ===========================================
321+
# Debian Nginx Images (Phase 2 - depends on base)
322+
# ===========================================
323+
build-debian-nginx:
324+
runs-on: ubuntu-latest
325+
needs: build-debian-base
326+
327+
strategy:
328+
matrix:
329+
type: ["", "-prod"]
330+
331+
steps:
332+
- name: Checkout code
333+
uses: actions/checkout@v5.0.0
334+
335+
- name: Setup QEMU
336+
uses: docker/setup-qemu-action@v3
337+
338+
- name: Setup Docker Buildx
339+
uses: docker/setup-buildx-action@v3
340+
341+
- name: Login to DockerHub
342+
uses: docker/login-action@v3
343+
if: github.ref == 'refs/heads/master' && github.repository == 'kool-dev/docker-php'
344+
with:
345+
username: ${{ secrets.DOCKER_USERNAME }}
346+
password: ${{ secrets.DOCKER_PASSWORD }}
347+
269348
- name: Build and export to Docker (Debian nginx)
270349
uses: docker/build-push-action@v6
271350
with:
@@ -325,10 +404,13 @@ jobs:
325404
push: true
326405
tags: kooldev/php:8.4-debian-nginx${{ matrix.type }}
327406

407+
# ===========================================
408+
# Downstream Triggers (after all builds complete)
409+
# ===========================================
328410
trigger-build-wordpress:
329411
name: Trigger Wordpress Build
330412
runs-on: ubuntu-latest
331-
needs: [build, build-debian]
413+
needs: [build-alpine-nginx, build-alpine-node, build-debian-nginx]
332414
steps:
333415
- name: Trigger build on kool-dev/docker-wordpress
334416
uses: benc-uk/workflow-dispatch@v1.2
@@ -341,7 +423,7 @@ jobs:
341423
trigger-extended-builds:
342424
name: Trigger Extended Builds
343425
runs-on: ubuntu-latest
344-
needs: [build, build-debian]
426+
needs: [build-alpine-nginx, build-alpine-node, build-debian-nginx]
345427
strategy:
346428
matrix:
347429
image:

0 commit comments

Comments
 (0)