-
Notifications
You must be signed in to change notification settings - Fork 139
117 lines (114 loc) · 4.41 KB
/
workflow.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
name: Docker PHP Images GitHub workflow
on:
pull_request:
branches:
- 'v4'
push:
branches:
- 'v4'
schedule:
- cron: '42 3 * * 0'
jobs:
test:
strategy:
fail-fast: false
matrix:
php_version: ['8.3','8.2','8.1','8.0','7.4','7.3','7.2']
variant: ['apache','cli','fpm']
# builder: [ {arch: "amd64", os: "ubuntu-latest"}, {arch: "arm64", os: "macos-latest"}]
builder: [ {arch: "amd64", os: "ubuntu-latest"}, {arch: "arm64", os: "ubuntu-latest"}]
runs-on: ${{ matrix.builder.os }}
name: Test ${{ matrix.php_version }}-${{ matrix.variant }} ${{ matrix.builder.arch }} only
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker
# /!\ this action is marked as experimental
# It's required only for macos
if: ${{ matrix.builder.os == 'macos-latest' }}
uses: docker-practice/actions-setup-docker@master
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build
run: |
PHP_VERSION="${{ matrix.php_version }}"
TAG_PREFIX="rc${GITHUB_RUN_ID}-" \
docker buildx bake \
--set "*.platform=linux/${{ matrix.builder.arch }}" \
--set "*.output=type=docker" \
--load \
php${PHP_VERSION//.}-${{ matrix.variant }}-all
- name: Display tags built
run: |
docker image ls --filter="reference=thecodingmachine/php" --format "{{.CreatedAt}}\t{{.Size}}\t{{.Repository}}:{{.Tag}}"
- name: Test
run: |
TAG_PREFIX="rc${GITHUB_RUN_ID}-" \
PHP_VERSION="${{ matrix.php_version }}" \
BRANCH="v4" \
VARIANT="${{ matrix.variant }}" \
PLATFORM="linux/${{ matrix.builder.arch }}" \
./tests-suite/bash_unit -f tap ./tests-suite/*.sh
publish:
# push ~ schedule
if: ${{ github.event_name == 'push' || github.event_name == 'schedule' }}
needs:
- test
runs-on: ubuntu-latest
name: Publish ${{ matrix.php_version }}-${{ matrix.variant }} multi-arch to dockerhub
strategy:
fail-fast: false
matrix:
php_version: ['8.3','8.2','8.1','8.0','7.4','7.3','7.2']
variant: ['apache','cli','fpm']
steps:
- name: Checkout
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.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Fetch minor version of php
run: |
# Build slim one
PHP_VERSION="${{ matrix.php_version }}"
TAG_PREFIX="rc${GITHUB_RUN_ID}-" \
docker buildx bake \
--set "*.platform=linux/amd64" \
--set "*.output=type=docker" \
--load \
php${PHP_VERSION//.}-slim-${{ matrix.variant }}
# Retrieve minor
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`
echo "PHP_PATCH_MINOR=${PHP_PATCH_MINOR}" >> $GITHUB_ENV
- name: Display tags to build
run: |
PHP_VERSION="${{ matrix.php_version }}"
PHP_PATCH_MINOR="${{ env.PHP_PATCH_MINOR }}" \
TAG_PREFIX="rc${GITHUB_RUN_ID}-" \
IS_RELEASE="1" \
docker buildx bake php${PHP_VERSION//.}-${{ matrix.variant }}-all --print --progress plain | jq ".target[].tags | join(\" \")" -r > "/tmp/tags.log"
cat "/tmp/tags.log"
- name: Build and push ${{ matrix.php_version }}-${{ matrix.variant }}
run: |
PHP_VERSION="${{ matrix.php_version }}"
PHP_PATCH_MINOR="${{ env.PHP_PATCH_MINOR }}" \
TAG_PREFIX="rc${GITHUB_RUN_ID}-" \
IS_RELEASE="1" \
docker buildx bake \
--set "*.platform=linux/amd64,linux/arm64" \
--set "*.output=type=registry" \
php${PHP_VERSION//.}-${{ matrix.variant }}-all
- name: Push artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.php_version }}-${{ matrix.variant }}
path: /tmp/tags.log
retention-days: 60