Skip to content

Build and publish images to Docker Hub #42

Build and publish images to Docker Hub

Build and publish images to Docker Hub #42

Workflow file for this run

##########################################################################
#
# WARNING: This file was generated by update.php.
#
# You can find the relevant template in the `/templates` folder.
#
name: Build and publish images to Docker Hub
on:
push:
branches:
- main
paths:
- 'images/**'
- '.github/workflows/docker-hub.yml'
workflow_dispatch:
# Once weekly On Sundays at 00:00 UTC.
schedule:
- cron: '0 0 * * 0'
env:
REGISTRY_USERNAME: spacedmonkey
REGISTRY_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
PACKAGE_REGISTRY_HOST:
PACKAGE_REGISTRY: spacedmonkey
PR_TAG:
# Cancels all previous workflow runs for pull requests that have not completed.
concurrency:
# The concurrency group contains the workflow name and the branch name for pull requests
# or the commit hash for any other events.
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
cancel-in-progress: true
jobs:
build-php-images:
name: PHP ${{ matrix.php }} Image
runs-on: ubuntu-latest
strategy:
matrix:
php: [ '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3' ]
env:
PHP_VERSION: ${{ matrix.php }}
PHP_LATEST: '7.4'
steps:
- name: Checkout repository
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
- name: Login to the package registry
run: |
echo "$REGISTRY_PASSWORD" | docker login $PACKAGE_REGISTRY_HOST -u "$REGISTRY_USERNAME" --password-stdin
- name: Build Docker image
run: docker build --build-arg PACKAGE_REGISTRY=$PACKAGE_REGISTRY --build-arg PR_TAG=$PR_TAG -t $PACKAGE_REGISTRY/php-blackfire:$PHP_VERSION-fpm$PR_TAG images/$PHP_VERSION/php
- name: Log Docker images
run: docker images
- name: Push Docker image
run: docker push $PACKAGE_REGISTRY/php-blackfire:$PHP_VERSION-fpm$PR_TAG
- name: Push image as latest
if: ${{ env.PHP_LATEST == env.PHP_VERSION }}
run: |
docker image tag $PACKAGE_REGISTRY/php-blackfire:$PHP_VERSION-fpm$PR_TAG $PACKAGE_REGISTRY/php-blackfire:latest$PR_TAG
docker images
docker push $PACKAGE_REGISTRY/php-blackfire:latest$PR_TAG