Files
docker-php/.github/workflows/main.yml
T

145 lines
4.7 KiB
YAML

name: Build, test and publish images
on:
push:
branches:
- master
pull_request:
types: [opened, synchronize]
jobs:
docker:
name: Build, test and publish
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', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1' ]
flavor: [ '', '-apache', '-fpm' ]
include:
- version: 'latest'
flavor: ''
services:
registry:
image: registry:2
ports:
- 5000:5000
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
with:
driver-opts: network=host
- name: Build image for testing
uses: docker/build-push-action@v2
with:
cache-from: type=registry,ref=chialab/php:${{ matrix.version }}${{ matrix.flavor }}
cache-to: type=inline
context: .
build-args: |
BASE_IMAGE=php:${{ matrix.version }}${{ matrix.flavor }}
tags: localhost:5000/chialab/php:${{ matrix.version }}${{ matrix.flavor }}
push: true
- name: Test image
env:
REGISTRY: localhost:5000/
VERSION: ${{ matrix.version }}${{ matrix.flavor }}
run: |
make test
- name: Build dev image for testing
uses: docker/build-push-action@v2
with:
cache-to: type=inline
context: ./dev
build-args: |
BASE_IMAGE=localhost:5000/chialab/php:${{ matrix.version }}${{ matrix.flavor }}
tags: localhost:5000/chialab/php-dev:${{ matrix.version }}${{ matrix.flavor }}
push: true
- name: Test dev image
env:
REGISTRY: localhost:5000/
VERSION: ${{ matrix.version }}${{ matrix.flavor }}
run: make -C dev test
- name: Build xhprof image for testing
uses: docker/build-push-action@v2
with:
cache-to: type=inline
context: ./xhprof
build-args: |
BASE_IMAGE=localhost:5000/chialab/php:${{ matrix.version }}${{ matrix.flavor }}
tags: localhost:5000/chialab/php-xhprof:${{ matrix.version }}${{ matrix.flavor }}
push: true
- name: Test xhprof image
env:
REGISTRY: localhost:5000/
VERSION: ${{ matrix.version }}${{ matrix.flavor }}
run: make -C xhprof test
- name: Login to DockerHub
if: "github.event_name != 'pull_request'"
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Login to GitHub Container Registry
if: "github.event_name != 'pull_request'"
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build image and push to registry
if: "github.event_name != 'pull_request'"
uses: docker/build-push-action@v2
with:
platforms: linux/amd64,linux/arm64
cache-from: type=registry,ref=chialab/php:${{ matrix.version }}${{ matrix.flavor }}
cache-to: type=inline
context: .
build-args: |
BASE_IMAGE=php:${{ matrix.version }}${{ matrix.flavor }}
tags:
chialab/php:${{ matrix.version }}${{ matrix.flavor }}
ghcr.io/chialab/php:${{ matrix.version }}${{ matrix.flavor }}
push: true
- name: Build dev image and push to registry
if: "github.event_name != 'pull_request'"
uses: docker/build-push-action@v2
with:
platforms: linux/amd64,linux/arm64
cache-to: type=inline
context: ./dev
build-args: |
BASE_IMAGE=ghcr.io/chialab/php:${{ matrix.version }}${{ matrix.flavor }}
tags: |
chialab/php-dev:${{ matrix.version }}${{ matrix.flavor }}
ghcr.io/chialab/php-dev:${{ matrix.version }}${{ matrix.flavor }}
push: true
- name: Build xhprof image (amd64 only) and push to registry
if: "github.event_name != 'pull_request'"
uses: docker/build-push-action@v2
with:
cache-to: type=inline
context: ./xhprof
build-args: |
BASE_IMAGE=ghcr.io/chialab/php:${{ matrix.version }}${{ matrix.flavor }}
tags: |
chialab/php-xhprof:${{ matrix.version }}${{ matrix.flavor }}
ghcr.io/chialab/php-xhprof:${{ matrix.version }}${{ matrix.flavor }}
push: true