mirror of
https://github.com/chialab/docker-php.git
synced 2026-08-24 02:24:16 -05:00
refactor: change workflow to also build ARM images
This commit is contained in:
+59
-28
@@ -8,52 +8,83 @@ on:
|
||||
types: [opened, synchronize]
|
||||
|
||||
jobs:
|
||||
|
||||
cancel-previous-runs:
|
||||
name: Cancel previous runs
|
||||
runs-on: ubuntu-20.04
|
||||
if: "!contains(github.event.commits[0].message, '[skip ci]') && !contains(github.event.commits[0].message, '[ci skip]')"
|
||||
steps:
|
||||
- uses: styfle/cancel-workflow-action@0.6.0
|
||||
with:
|
||||
access_token: ${{ github.token }}
|
||||
|
||||
build-test-push:
|
||||
docker:
|
||||
name: Build, test and publish
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-latest
|
||||
if: "!contains(github.event.commits[0].message, '[skip ci]') && !contains(github.event.commits[0].message, '[ci skip]')"
|
||||
needs: cancel-previous-runs
|
||||
strategy:
|
||||
matrix:
|
||||
version: [ '5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0' ]
|
||||
flavor: [ '', '-apache', '-fpm' ]
|
||||
version: [ '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0' ]
|
||||
flavor: [ '', 'apache', 'fpm' ]
|
||||
include:
|
||||
- version: 'latest'
|
||||
flavor: ''
|
||||
env:
|
||||
VERSION: "${{ matrix.version }}${{ matrix.flavor }}"
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Build images
|
||||
- name: Prepare context path and image tag
|
||||
id: prepare-path-tag
|
||||
run: |
|
||||
make build VERSION=${VERSION}
|
||||
make -C dev build VERSION=${VERSION}
|
||||
echo "::set-output name=context-path::${{ matrix.version != 'latest' && matrix.version || '' }}${{ matrix.flavor != '' && format('/{0}', matrix.flavor) || '' }}"
|
||||
echo "::set-output name=image-tag::${{ matrix.version }}${{ matrix.flavor != '' && format('-{0}', matrix.flavor) || '' }}"
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v1
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
|
||||
- name: Build image for testing
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
cache-from: type=registry,ref=chialab/php:${{ steps.prepare-path-tag.outputs.image-tag }}
|
||||
cache-to: type=inline
|
||||
context: ./${{ steps.prepare-path-tag.outputs.context-path }}
|
||||
tags: chialab/php:${{ steps.prepare-path-tag.outputs.image-tag }}
|
||||
load: true
|
||||
|
||||
- name: Build dev image for testing
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
cache-from: type=registry,ref=chialab/php-dev:${{ steps.prepare-path-tag.outputs.image-tag }}
|
||||
cache-to: type=inline
|
||||
context: ./dev/${{ steps.prepare-path-tag.outputs.context-path }}
|
||||
tags: chialab/php-dev:${{ steps.prepare-path-tag.outputs.image-tag }}
|
||||
load: true
|
||||
|
||||
- name: Test images
|
||||
env:
|
||||
VERSION: "${{ matrix.version }}${{ matrix.flavor }}"
|
||||
run: |
|
||||
make test VERSION=${VERSION}
|
||||
make -C dev test VERSION=${VERSION}
|
||||
|
||||
- name: Login to Docker HUB
|
||||
- name: Login to DockerHub
|
||||
if: "github.event_name != 'pull_request'"
|
||||
run: echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
|
||||
env:
|
||||
DOCKER_PASSWORD: "${{ secrets.DOCKER_PASSWORD }}"
|
||||
DOCKER_USERNAME: "${{ secrets.DOCKER_USERNAME }}"
|
||||
uses: docker/login-action@v1
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
|
||||
- name: Publish images
|
||||
- name: Build image and push to registry
|
||||
if: "github.event_name != 'pull_request'"
|
||||
run: |
|
||||
make push VERSION=${VERSION}
|
||||
make -C dev push VERSION=${VERSION}
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
platforms: linux/amd64,linux/arm64
|
||||
cache-from: type=registry,ref=chialab/php:${{ steps.prepare-path-tag.outputs.image-tag }}
|
||||
cache-to: type=inline
|
||||
context: ./${{ steps.prepare-path-tag.outputs.context-path }}
|
||||
tags: chialab/php:${{ steps.prepare-path-tag.outputs.image-tag }}
|
||||
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-from: type=registry,ref=chialab/php-dev:${{ steps.prepare-path-tag.outputs.image-tag }}
|
||||
cache-to: type=inline
|
||||
context: ./dev/${{ steps.prepare-path-tag.outputs.context-path }}
|
||||
tags: chialab/php-dev:${{ steps.prepare-path-tag.outputs.image-tag }}
|
||||
push: true
|
||||
|
||||
Reference in New Issue
Block a user