Skip to content

Try using ghcr.io for base images #133

Try using ghcr.io for base images

Try using ghcr.io for base images #133

name: Publish slic-wordpress-php Docker image
on:
push:
branches:
- main
- '[0-9]+.[0-9]+.[0-9]+'
release:
types: [published]
jobs:
publish-wordpress-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
matrix:
wp_version: [ '6.2' ]
php_version: [ '8.0', '8.1', '8.2' ]
include:
# No WordPress image for version 6.2+ and PHP 7.3: use the latest 5.9 version.
# This version is NOT updated in the containers/wordpress/Dockerfile for back-compatibility.
- wp_version: '5.9'
php_version: '7.3'
# No WordPress image for version 6.2+ and PHP 7.4: use the latest 6.1.1 version.
# See containers/wordpress/Dockerfile for the wp-cli update to version 6.2.
- wp_version: '6.1.1'
php_version: '7.4'
# Use the latest 6.5 WordPress version for PHP 8.3.
- wp_version: '6.5'
php_version: '8.3'
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}-wordpress-php${{ matrix.php_version }}
tags: |
type=edge,branch=main
type=ref,event=branch
type=ref,event=tag
type=semver,pattern={{raw}}
- uses: docker/setup-buildx-action@v3
- name: Build and push Docker image
uses: docker/build-push-action@v5
continue-on-error: true
with:
context: containers/wordpress
file: containers/wordpress/Dockerfile
push: true
pull: true
tags: |
${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha,scope=${{ matrix.wp_version }}-${{ matrix.php_version }}
cache-to: type=gha,mode=max,scope=${{ matrix.wp_version }}-${{ matrix.php_version }}
build-args: |
PHP_VERSION=${{ matrix.php_version }}
WP_VERSION=${{ matrix.wp_version }}
platforms: linux/amd64,linux/arm64