Skip to content

Commit e6a3628

Browse files
committed
Add a fallback action for v4
1 parent 29c6910 commit e6a3628

File tree

2 files changed

+117
-1
lines changed

2 files changed

+117
-1
lines changed

.github/workflows/legacy.yml

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
name: build v4 legacy
2+
3+
on:
4+
schedule:
5+
- cron: '42 5 * * 0#1' # First Sunday
6+
- cron: '42 5 * * 0#3' # Third Sunday
7+
workflow_dispatch:
8+
9+
jobs:
10+
test:
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
php_version: ['8.4', '8.3','8.2','8.1','8.0','7.4']
15+
variant: ['apache','cli','fpm']
16+
# builder: [ {arch: "amd64", os: "ubuntu-latest"}, {arch: "arm64", os: "macos-latest"}]
17+
builder: [ {arch: "amd64", os: "ubuntu-latest"}, {arch: "arm64", os: "ubuntu-latest"}]
18+
runs-on: ${{ matrix.builder.os }}
19+
name: Test ${{ matrix.php_version }}-${{ matrix.variant }} ${{ matrix.builder.arch }} only
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
with:
24+
ref: v4
25+
- name: Set up Docker
26+
# /!\ this action is marked as experimental
27+
# It's required only for macos
28+
if: ${{ matrix.builder.os == 'macos-latest' }}
29+
uses: docker-practice/actions-setup-docker@master
30+
- name: Set up QEMU
31+
uses: docker/setup-qemu-action@v3
32+
- name: Set up Docker Buildx
33+
uses: docker/setup-buildx-action@v3
34+
- name: Build
35+
run: |
36+
PHP_VERSION="${{ matrix.php_version }}"
37+
TAG_PREFIX="rc${GITHUB_RUN_ID}-" \
38+
docker buildx bake \
39+
--set "*.platform=linux/${{ matrix.builder.arch }}" \
40+
--set "*.output=type=docker" \
41+
--load \
42+
php${PHP_VERSION//.}-${{ matrix.variant }}-all
43+
- name: Display tags built
44+
run: |
45+
docker image ls --filter="reference=thecodingmachine/php" --format "{{.CreatedAt}}\t{{.Size}}\t{{.Repository}}:{{.Tag}}"
46+
- name: Test
47+
run: |
48+
TAG_PREFIX="rc${GITHUB_RUN_ID}-" \
49+
PHP_VERSION="${{ matrix.php_version }}" \
50+
BRANCH="v4" \
51+
VARIANT="${{ matrix.variant }}" \
52+
PLATFORM="linux/${{ matrix.builder.arch }}" \
53+
./tests-suite/bash_unit -f tap ./tests-suite/*.sh
54+
55+
publish:
56+
# push ~ schedule
57+
if: ${{ github.event_name == 'push' || github.event_name == 'schedule' }}
58+
needs:
59+
- test
60+
runs-on: ubuntu-latest
61+
name: Publish ${{ matrix.php_version }}-${{ matrix.variant }} multi-arch to dockerhub
62+
strategy:
63+
fail-fast: false
64+
matrix:
65+
php_version: ['8.4', '8.3','8.2','8.1','8.0','7.4']
66+
variant: ['apache','cli','fpm']
67+
steps:
68+
- name: Checkout
69+
uses: actions/checkout@v4
70+
- name: Set up QEMU
71+
uses: docker/setup-qemu-action@v3
72+
- name: Set up Docker Buildx
73+
uses: docker/setup-buildx-action@v3
74+
- name: Login to DockerHub
75+
uses: docker/login-action@v3
76+
with:
77+
username: ${{ secrets.DOCKERHUB_USERNAME }}
78+
password: ${{ secrets.DOCKERHUB_TOKEN }}
79+
- name: Fetch minor version of php
80+
run: |
81+
# Build slim one
82+
PHP_VERSION="${{ matrix.php_version }}"
83+
TAG_PREFIX="rc${GITHUB_RUN_ID}-" \
84+
docker buildx bake \
85+
--set "*.platform=linux/amd64" \
86+
--set "*.output=type=docker" \
87+
--load \
88+
php${PHP_VERSION//.}-slim-${{ matrix.variant }}
89+
# Retrieve minor
90+
PHP_PATCH_MINOR=`docker run --rm thecodingmachine/php:rc${GITHUB_RUN_ID}-${{ matrix.php_version }}-v4-slim-${{ matrix.variant }} php -v | head -n1 | grep -P '\d+\.\d+\.\d+' -o | head -n1`
91+
echo "PHP_PATCH_MINOR=${PHP_PATCH_MINOR}" >> $GITHUB_ENV
92+
- name: Display tags to build
93+
run: |
94+
PHP_VERSION="${{ matrix.php_version }}"
95+
PHP_PATCH_MINOR="${{ env.PHP_PATCH_MINOR }}" \
96+
TAG_PREFIX="rc${GITHUB_RUN_ID}-" \
97+
IS_RELEASE="1" \
98+
docker buildx bake php${PHP_VERSION//.}-${{ matrix.variant }}-all --print --progress plain | jq ".target[].tags | join(\" \")" -r > "/tmp/tags.log"
99+
cat "/tmp/tags.log"
100+
- name: Build and push ${{ matrix.php_version }}-${{ matrix.variant }}
101+
run: |
102+
PHP_VERSION="${{ matrix.php_version }}"
103+
PHP_PATCH_MINOR="${{ env.PHP_PATCH_MINOR }}" \
104+
TAG_PREFIX="rc${GITHUB_RUN_ID}-" \
105+
IS_RELEASE="1" \
106+
docker buildx bake \
107+
--set "*.platform=linux/amd64,linux/arm64" \
108+
--set "*.output=type=registry" \
109+
php${PHP_VERSION//.}-${{ matrix.variant }}-all
110+
- name: Push artifacts
111+
uses: actions/upload-artifact@v3
112+
with:
113+
name: ${{ matrix.php_version }}-${{ matrix.variant }}
114+
path: /tmp/tags.log
115+
retention-days: 60

.github/workflows/workflow.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Docker PHP Images GitHub workflow
1+
name: Auto test and build v5
22

33
on:
44
pull_request:
@@ -9,6 +9,7 @@ on:
99
- 'v5'
1010
schedule:
1111
- cron: '42 3 * * 0'
12+
workflow_dispatch:
1213

1314
jobs:
1415
test:

0 commit comments

Comments
 (0)