Skip to content

php

php #46

Workflow file for this run

name: php
on:
workflow_dispatch:
schedule:
- cron: '0 0 * * 0'
push:
branches:
- main
paths:
- '.github/workflows/php.yml'
- 'php/**/Dockerfile'
pull_request:
types: [opened, reopened, synchronize]
branches:
- main
paths:
- '.github/workflows/php.yml'
- 'php/**/Dockerfile'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 60
strategy:
fail-fast: true
matrix:
version: ["7.4", "8.0", "8.1", "8.2"]
variant: ["fpm", "cli"]
env:
IMAGE_REGISTRY: ghcr.io
IMAGE_TAG: ghcr.io/${{ github.repository_owner }}/php:${{ matrix.version }}-${{ matrix.variant }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.IMAGE_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: metadata
uses: docker/metadata-action@v5
with:
images: ${{ env.IMAGE_TAG }}
- name: Build and push
uses: docker/build-push-action@v6
with:
push: ${{ github.ref == 'refs/heads/main' && github.event_name != 'pull_request' }}
context: ./php/${{ matrix.version }}
file: ./php/${{ matrix.version }}/${{ matrix.variant }}/Dockerfile
labels: ${{ steps.metadata.outputs.labels }}
tags: ${{ env.IMAGE_TAG }}
platforms: linux/amd64,linux/arm64
provenance: false
- name: Test run image
run: |
ver=$(docker run --rm ${{ env.IMAGE_TAG }} php -v | grep -o "^PHP [0-9].[0-9]");
if [ "$ver" == "PHP ${{ matrix.version }}" ];
then
echo $ver;
else
exit 1;
fi
wp:
uses: ./.github/workflows/wp.yml
needs: [build]
if: ${{ success() }}
secrets: inherit