V5 first draft #436
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Docker PHP Images GitHub workflow | |
on: | |
pull_request: | |
branches: | |
- 'v5' | |
push: | |
branches: | |
- 'v5' | |
# FIXME disabled for testing purpose | |
# schedule: | |
# - cron: '42 3 * * 0' | |
jobs: | |
test: | |
strategy: | |
fail-fast: false | |
matrix: | |
php_version: ['8.1'] | |
variant: ['cli'] | |
# 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@v3 | |
- 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@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Build regular and dev for current arch | |
run: | | |
TAG_PREFIX="rc${GITHUB_RUN_ID}-" \ | |
REPO=thecodingmachine/php-alpha \ | |
docker buildx bake \ | |
--set "*.platform=linux/${{ matrix.builder.arch }}" \ | |
--set "*.output=type=docker" \ | |
--load \ | |
${{ matrix.php_version }}-${{ matrix.variant }}-all | |
- name: Display tags built | |
run: | | |
docker image ls --filter="reference=thecodingmachine/php-alpha" --format "{{.CreatedAt}}\t{{.Size}}\t{{.Repository}}:{{.Tag}}" | |
- name: Test retrocompatibility | |
continue-on-error: true # FIXME / WIP | |
run: | | |
TAG_PREFIX="rc${GITHUB_RUN_ID}-" \ | |
PHP_VERSION="${{ matrix.php_version }}" \ | |
REPO=thecodingmachine/php-alpha \ | |
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.1'] | |
variant: ['cli'] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- 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 regular one | |
TAG_PREFIX="rc${GITHUB_RUN_ID}-" \ | |
REPO=thecodingmachine/php-alpha \ | |
docker buildx bake \ | |
--set "*.platform=linux/amd64" \ | |
--set "*.output=type=docker" \ | |
--load \ | |
${{ matrix.php_version }}-${{ 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_PATCH_MINOR="${{ env.PHP_PATCH_MINOR }}" \ | |
TAG_PREFIX="rc${GITHUB_RUN_ID}-" \ | |
REPO=thecodingmachine/php-alpha \ | |
IS_RELEASE="1" \ | |
docker buildx bake ${{ matrix.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_PATCH_MINOR="${{ env.PHP_PATCH_MINOR }}" \ | |
TAG_PREFIX="rc${GITHUB_RUN_ID}-" \ | |
REPO=thecodingmachine/php-alpha \ | |
IS_RELEASE="1" \ | |
docker buildx bake \ | |
--set "*.platform=linux/amd64,linux/arm64" \ | |
--set "*.output=type=registry" \ | |
${{ matrix.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 |