Skip to content

Build and push containers #863

Build and push containers

Build and push containers #863

name: "Build and push containers"
on:
schedule:
- cron: '31 19 * * *'
push:
branches: [ main ]
jobs:
release-container:
name: "Push Docker image to GitHub Packages"
runs-on: "ubuntu-latest"
strategy:
matrix:
php-version:
- "8.1"
- "8.2"
- "8.3"
base-image:
- "alpine"
steps:
- name: "Checkout"
uses: "actions/checkout@v4"
- name: "Docker meta"
id: "meta"
uses: "docker/metadata-action@v5"
with:
flavor: |
latest=false
images: |
core23/jenkins-php-agent
ghcr.io/core23/jenkins-php-agent
tags: |
type=raw,value=${{ matrix.php-version }}-${{ matrix.base-image }}
type=raw,value=${{ matrix.php-version }},enable=${{ startsWith(matrix.base-image, 'alpine') }}
- name: "Setup QEMU"
uses: "docker/setup-qemu-action@v3"
- name: "Setup Docker Buildx"
uses: "docker/setup-buildx-action@v3"
- name: "Login to GitHub Container Registry"
uses: "docker/login-action@v3"
with:
registry: ghcr.io
username: ${{ secrets.CONTAINER_GH_USERNAME }}
password: ${{ secrets.CONTAINER_GH_PAT }}
- name: "Login to DockerHub Registry"
uses: "docker/login-action@v3"
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: "Build and push"
uses: "docker/build-push-action@v6"
with:
context: "php/${{ matrix.base-image }}/${{ matrix.php-version }}"
platforms: "linux/amd64"
push: true
tags: "${{ steps.meta.outputs.tags }}"
labels: "${{ steps.meta.outputs.labels }}"