Skip to content

Build, test and publish compatibility images #6

Build, test and publish compatibility images

Build, test and publish compatibility images #6

Workflow file for this run

name: Build, test and publish compatibility images
on:
schedule:
# chosen by fair dice roll
- cron: '42 18 * * 4'
push:
branches:
- main
pull_request:
types: [opened, synchronize]
jobs:
test:
name: Build and test images
runs-on: ubuntu-latest
if: ${{ !contains(github.event.commits[0].message, '[skip ci]') && !contains(github.event.commits[0].message, '[ci skip]') }}
strategy:
matrix:
version: [ '5.6' ]
flavor: [ '', '-apache', '-fpm' ]
services:
registry:
image: registry:2
ports:
- 5000:5000
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Build image for testing
uses: docker/build-push-action@v5
with:
cache-from: type=registry,ref=chialab/php-compat:${{ matrix.version }}${{ matrix.flavor }}
cache-to: type=inline
context: ./compat
file: ${{ format('compat/{0}.{1}{2}', 'Dockerfile', matrix.version, matrix.flavor) }}
tags: localhost:5000/chialab/php-compat:${{ matrix.version }}${{ matrix.flavor }}
push: true
- name: Test image
env:
REGISTRY: localhost:5000/
VERSION: ${{ matrix.version }}${{ matrix.flavor }}
run: 'docker pull localhost:5000/chialab/php-compat:${{ matrix.version }}${{ matrix.flavor }} && make -C compat test'
publish:
name: Build and publish multi-architecture images
runs-on: ubuntu-latest
needs: test
if: ${{ github.event_name != 'pull_request' && !contains(github.event.commits[0].message, '[skip ci]') && !contains(github.event.commits[0].message, '[ci skip]') }}
strategy:
matrix:
version: [ '5.6' ]
flavor: [ '', '-apache', '-fpm' ]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
run: |
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver-opts: network=host
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build image and push to registry
uses: docker/build-push-action@v5
with:
platforms: linux/amd64,linux/arm64
cache-from: type=registry,ref=chialab/php-compat:${{ matrix.version }}${{ matrix.flavor }}
cache-to: type=inline
context: ./compat
file: ${{ format('compat/{0}.{1}{2}', 'Dockerfile', matrix.version, matrix.flavor) }}
tags: |
chialab/php-compat:${{ matrix.version }}${{ matrix.flavor }}
ghcr.io/chialab/php-compat:${{ matrix.version }}${{ matrix.flavor }}
push: true