Skip to content

Commit 8c3a1de

Browse files
committed
FIX Gitlab-ci
1 parent 81b61a8 commit 8c3a1de

File tree

1 file changed

+66
-30
lines changed

1 file changed

+66
-30
lines changed

.github/workflows/workflow.yml

Lines changed: 66 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -11,55 +11,91 @@ on:
1111
# - cron: '42 3 * * 0'
1212

1313
jobs:
14-
build_test_maybe_release:
14+
build:
1515
strategy:
16+
fail-fast: false
1617
matrix:
1718
php_version: ['8.1','8.0','7.4', '7.3','7.2']
1819
variant: ['apache','cli','fpm']
19-
runs-on: ubuntu-latest
20+
# builder: [ {arch: "amd64", os: "ubuntu-latest"}, {arch: "arm64", os: "macos-latest"}]
21+
builder: [ {arch: "amd64", os: "ubuntu-latest"}, {arch: "arm64", os: "ubuntu-latest"}]
22+
runs-on: ${{ matrix.builder.os }}
23+
# runs-on: self-hosted
24+
name: Build & test ${{ matrix.php_version }}-${{ matrix.variant }} (${{ matrix.builder.arch }})
2025
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v3
28+
- name: Set up Docker
29+
# /!\ this action is marked as experimental
30+
# It's required only for macos
31+
if: ${{ matrix.builder.os == 'macos-latest' }}
32+
uses: docker-practice/actions-setup-docker@master
2133
- name: Set up QEMU
22-
uses: docker/setup-qemu-action@v1
34+
uses: docker/setup-qemu-action@v2
2335
- name: Set up Docker Buildx
24-
uses: docker/setup-buildx-action@v1
36+
uses: docker/setup-buildx-action@v2
37+
- name: Build
38+
run: |
39+
PHP_VERSION="${{ matrix.php_version }}"
40+
TAG_PREFIX="rc${GITHUB_SHA::7}-" \
41+
docker buildx bake \
42+
--set "*.platform=linux/${{ matrix.builder.arch }}" \
43+
--set "*.output=type=docker" \
44+
--load \
45+
php${PHP_VERSION//.}-${{ matrix.variant }}-all
46+
- name: Display tags built
47+
run: |
48+
docker image ls --filter="reference=thecodingmachine/php" --format "{{.CreatedAt}}\t{{.Size}}\t{{.Repository}}:{{.Tag}}"
49+
- name: Test
50+
run: |
51+
TAG_PREFIX="rc${GITHUB_SHA::7}-" \
52+
PHP_VERSION="${{ matrix.php_version }}" \
53+
BRANCH="v4" \
54+
VARIANT="${{ matrix.variant }}" \
55+
PLATFORM="linux/${{ matrix.builder.arch }}" \
56+
./tests-suite/bash_unit -f tap ./tests-suite/*.sh
57+
58+
publish:
59+
# push ~ schedule
60+
# FIXME : re-enable after testing
61+
# if: ${{ github.event_name == 'push' || github.event_name == 'schedule' }}
62+
needs:
63+
- build
64+
runs-on: ubuntu-latest
65+
name: Publish multi-arch to dockerhub
66+
strategy:
67+
fail-fast: false
68+
matrix:
69+
php_version: ['8.1','8.0','7.4', '7.3','7.2']
70+
variant: ['apache','cli','fpm']
71+
steps:
2572
- name: Checkout
26-
uses: actions/checkout@v1
27-
# - name: Build locally
28-
# run: |
29-
# PHP_VERSION="${{ matrix.php_version }}"
30-
# docker buildx bake --load \
31-
# --set "*.platform=linux/amd64" \
32-
# php${PHP_VERSION//.}-slim-${{ matrix.variant }}
33-
# docker buildx bake --load \
34-
# --set "*.platform=linux/amd64" \
35-
# php${PHP_VERSION//.}-${{ matrix.variant }}-all
36-
# PHP_VERSION_MINOR=`docker run --rm thecodingmachine/php:${PHP_VERSION}-v4-slim-cli php -v | head -n1 | grep -P '\d+\.\d+\.\d+' -o | head -n1`
37-
# echo "PHP_VERSION_MINOR=${PHP_VERSION_MINOR}" >> $GITHUB_ENV
38-
# echo "PHP Version : ${PHP_VERSION_MINOR}" >> $GITHUB_STEP_SUMMARY
39-
# docker images --filter=reference=thecodingmachine/php >> $GITHUB_STEP_SUMMARY
40-
# - name: Test ${{ matrix.variant }}
41-
# run: |
42-
# PHP_VERSION="${{ matrix.php_version }}" BRANCH=v4 VARIANT=${{ matrix.variant }} ./test-image.sh
43-
# echo "${{ matrix.variant }} variant OK" >> $GITHUB_STEP_SUMMARY
73+
uses: actions/checkout@v3
74+
- name: Set up QEMU
75+
uses: docker/setup-qemu-action@v2
76+
- name: Set up Docker Buildx
77+
uses: docker/setup-buildx-action@v2
4478
- name: Login to DockerHub
45-
# Merge ~ push.
46-
if: ${{ github.event_name == 'push' || github.event_name == 'schedule' }}
4779
uses: docker/login-action@v1
4880
with:
4981
username: ${{ secrets.DOCKERHUB_USERNAME }}
5082
password: ${{ secrets.DOCKERHUB_TOKEN }}
51-
- name: Build and push to repository
52-
# Merge ~ push.
53-
if: ${{ github.event_name == 'push' || github.event_name == 'schedule' }}
83+
- name: Build and push ${{ matrix.php_version }}-${{ matrix.variant }} as multiarch (amd64 and arm64)
5484
run: |
55-
PHP_VERSION="${{ matrix.php_version }}"
85+
TAG_PREFIX="rc${GITHUB_SHA::7}-" \
5686
docker buildx bake \
5787
--set "*.platform=linux/amd64,linux/arm64" \
5888
--set "*.output=type=registry" \
5989
php${PHP_VERSION//.}-slim-${{ matrix.variant }}
60-
PHP_PATCH_MINOR=`docker run --rm thecodingmachine/php:${PHP_VERSION}-v4-slim-cli php -v | head -n1 | grep -P '\d+\.\d+\.\d+' -o | head -n1` \
90+
PHP_PATCH_MINOR=`docker run --rm thecodingmachine/php:rc-${GITHUB_SHA::7}-${{ matrix.php_version }}-v4-slim-${{ matrix.variant }} php -v | head -n1 | grep -P '\d+\.\d+\.\d+' -o | head -n1`
91+
PHP_VERSION="${{ matrix.php_version }}"
92+
93+
TAG_PREFIX="rc${GITHUB_SHA::7}-" \
94+
PHP_PATCH_MINOR="${PHP_VERSION_MINOR}" \
6195
docker buildx bake \
6296
--set "*.platform=linux/amd64,linux/arm64" \
6397
--set "*.output=type=registry" \
6498
php${PHP_VERSION//.}-${{ matrix.variant }}-all
65-
docker images --filter=reference=thecodingmachine/php >> $GITHUB_STEP_SUMMARY
99+
- name: Display tags built
100+
run: |
101+
docker image ls --filter="reference=thecodingmachine/php" --format "{{.CreatedAt}}\t{{.Size}}\t{{.Repository}}:{{.Tag}}"

0 commit comments

Comments
 (0)