Skip to content

Build And Push PHP Docker Images #109

Build And Push PHP Docker Images

Build And Push PHP Docker Images #109

on:
schedule:
- cron: '0 0 * * 0,3'
push:
branches:
- 'master'
name: "Build And Push PHP Docker Images"
jobs:
build-and-push-docker:
name: "Build And Push PHP Docker Images"
runs-on: ${{ matrix.operating-system }}
strategy:
fail-fast: false
matrix:
php-version:
- "8.0"
- "8.1"
- "8.2"
php-target:
- "cli"
- "fpm"
- "zts"
operating-system:
- "ubuntu-latest"
steps:
- name: "Checkout"
uses: actions/checkout@master
- name: "Install Docker Composer 2.x"
run: |
curl -fL https://raw.githubusercontent.com/docker/compose-switch/master/install_on_linux.sh | sudo sh
sudo update-alternatives --display docker-compose
docker -v
docker-compose -v
- name: "Build ${{ matrix.php-target }} ${{ matrix.php-version }}"
working-directory: php
env:
PHP_VERSION: ${{ matrix.php-version }}
PHP_TARGET: ${{ matrix.php-target }}
DOCKER_REGISTRY: "ghcr.io/prooph/docker-files/"
run: docker-compose build
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: "Push PHP images to ghcr.io"
working-directory: php
env:
PHP_VERSION: ${{ matrix.php-version }}
PHP_TARGET: ${{ matrix.php-target }}
DOCKER_REGISTRY: "ghcr.io/prooph/docker-files/"
run: "docker-compose push"
- name: "Push Composer images to ghcr.io"
working-directory: php
env:
PHP_VERSION: ${{ matrix.php-version }}
PHP_TARGET: ${{ matrix.php-target }}
DOCKER_REGISTRY: "ghcr.io/prooph/docker-files/"
if: matrix.php-target == 'cli' || matrix.php-target == 'zts'
run: |
docker tag ${DOCKER_REGISTRY}composer:${PHP_VERSION}-${PHP_TARGET} ${DOCKER_REGISTRY}composer:${PHP_VERSION}
docker push ${DOCKER_REGISTRY}composer:${PHP_VERSION}
docker tag ${DOCKER_REGISTRY}composer:${PHP_VERSION}-${PHP_TARGET}-1x ${DOCKER_REGISTRY}composer:${PHP_VERSION}-1x
docker push ${DOCKER_REGISTRY}composer:${PHP_VERSION}-1x
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: "Push PHP images to Docker HUB"
working-directory: php
env:
PHP_VERSION: ${{ matrix.php-version }}
PHP_TARGET: ${{ matrix.php-target }}
DOCKER_REGISTRY: "ghcr.io/prooph/docker-files/"
DOCKER_HUB_REGISTRY: "prooph/"
run: |
docker tag ${DOCKER_REGISTRY}php:${PHP_VERSION}-${PHP_TARGET} ${DOCKER_HUB_REGISTRY}php:${PHP_VERSION}-${PHP_TARGET}
docker push ${DOCKER_HUB_REGISTRY}php:${PHP_VERSION}-${PHP_TARGET}
docker tag ${DOCKER_REGISTRY}php:${PHP_VERSION}-${PHP_TARGET}-blackfire ${DOCKER_HUB_REGISTRY}php:${PHP_VERSION}-${PHP_TARGET}-blackfire
docker push ${DOCKER_HUB_REGISTRY}php:${PHP_VERSION}-${PHP_TARGET}-blackfire
docker tag ${DOCKER_REGISTRY}php:${PHP_VERSION}-${PHP_TARGET}-opcache ${DOCKER_HUB_REGISTRY}php:${PHP_VERSION}-${PHP_TARGET}-opcache
docker push ${DOCKER_HUB_REGISTRY}php:${PHP_VERSION}-${PHP_TARGET}-opcache
docker tag ${DOCKER_REGISTRY}php:${PHP_VERSION}-${PHP_TARGET}-xdebug ${DOCKER_HUB_REGISTRY}php:${PHP_VERSION}-${PHP_TARGET}-xdebug
docker push ${DOCKER_HUB_REGISTRY}php:${PHP_VERSION}-${PHP_TARGET}-xdebug
- name: "Push Composer images to Docker HUB"
working-directory: php
env:
PHP_VERSION: ${{ matrix.php-version }}
PHP_TARGET: ${{ matrix.php-target }}
DOCKER_REGISTRY: "ghcr.io/prooph/docker-files/"
DOCKER_HUB_REGISTRY: "prooph/"
if: matrix.php-target == 'cli' || matrix.php-target == 'zts'
run: |
docker tag ${DOCKER_REGISTRY}composer:${PHP_VERSION}-${PHP_TARGET} ${DOCKER_HUB_REGISTRY}composer:${PHP_VERSION}
docker push ${DOCKER_HUB_REGISTRY}composer:${PHP_VERSION}
docker tag ${DOCKER_REGISTRY}composer:${PHP_VERSION}-${PHP_TARGET}-1x ${DOCKER_HUB_REGISTRY}composer:${PHP_VERSION}-1x
docker push ${DOCKER_HUB_REGISTRY}composer:${PHP_VERSION}-1x