refactor: use local registry for testing images, push to both DockerHub and GitHub Container Registry

This commit is contained in:
Paolo Cuffiani
2022-04-21 18:36:00 +02:00
parent c2edb3d171
commit 81a8a1dd96
7 changed files with 102 additions and 78 deletions
+66 -42
View File
@@ -8,7 +8,6 @@ on:
types: [opened, synchronize]
jobs:
docker:
name: Build, test and publish
runs-on: ubuntu-latest
@@ -20,14 +19,22 @@ jobs:
include:
- version: 'latest'
flavor: ''
services:
registry:
image: registry:2
ports:
- 5000:5000
steps:
- uses: actions/checkout@v2
- 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
@@ -36,15 +43,48 @@ jobs:
cache-to: type=inline
context: .
build-args: |
BASE_IMAGE=${{ matrix.version }}${{ matrix.flavor }}
tags: chialab/php:${{ matrix.version }}${{ matrix.flavor }}
load: true
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 VERSION=${VERSION}
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'"
@@ -53,6 +93,14 @@ jobs:
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
@@ -62,25 +110,12 @@ jobs:
cache-to: type=inline
context: .
build-args: |
BASE_IMAGE=${{ matrix.version }}${{ matrix.flavor }}
tags: chialab/php:${{ matrix.version }}${{ matrix.flavor }}
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 for testing
uses: docker/build-push-action@v2
with:
cache-to: type=inline
context: ./dev
build-args: |
BASE_IMAGE=${{ matrix.version }}${{ matrix.flavor }}
tags: chialab/php-dev:${{ matrix.version }}${{ matrix.flavor }}
load: true
- name: Test dev image
env:
VERSION: ${{ matrix.version }}${{ matrix.flavor }}
run: make -C dev test VERSION=${VERSION}
- name: Build dev image and push to registry
if: "github.event_name != 'pull_request'"
uses: docker/build-push-action@v2
@@ -89,25 +124,12 @@ jobs:
cache-to: type=inline
context: ./dev
build-args: |
BASE_IMAGE=${{ matrix.version }}${{ matrix.flavor }}
tags: chialab/php-dev:${{ matrix.version }}${{ matrix.flavor }}
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 for testing
uses: docker/build-push-action@v2
with:
cache-to: type=inline
context: ./xhprof
build-args: |
BASE_IMAGE=${{ matrix.version }}${{ matrix.flavor }}
tags: chialab/php-xhprof:${{ matrix.version }}${{ matrix.flavor }}
load: true
- name: Test xhprof image
env:
VERSION: ${{ matrix.version }}${{ matrix.flavor }}
run: make -C xhprof test VERSION=${VERSION}
- name: Build xhprof image (amd64 only) and push to registry
if: "github.event_name != 'pull_request'"
uses: docker/build-push-action@v2
@@ -115,6 +137,8 @@ jobs:
cache-to: type=inline
context: ./xhprof
build-args: |
BASE_IMAGE=${{ matrix.version }}${{ matrix.flavor }}
tags: chialab/php-xhprof:${{ matrix.version }}${{ matrix.flavor }}
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