Skip to content

Modernize

Modernize #19

Workflow file for this run

name: Build and Push Docker Images
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
release:
types: [ published ]
env:
REGISTRY: ghcr.io
IMAGE_NAME: docker-apache-php
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
matrix:
php_version: ['7.0', '8.2']
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch,suffix=-php${{ matrix.php_version }}-apache2
type=ref,event=pr,suffix=-php${{ matrix.php_version }}-apache2
type=semver,pattern={{version}},suffix=-php${{ matrix.php_version }}-apache2
type=semver,pattern={{major}}.{{minor}},suffix=-php${{ matrix.php_version }}-apache2
type=raw,value=php${{ matrix.php_version }}-apache2,enable={{is_default_branch}}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./php${{ matrix.php_version }}-Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max