Build the PHP 7.2 Apache2 container #975
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- | |
| name: Build the PHP 7.2 Apache2 container | |
| on: | |
| push: | |
| paths: | |
| - "php72-apache2/**" | |
| - ".github/workflows/build-php72-apache2.yaml" | |
| schedule: | |
| - cron: '0 7 * * *' | |
| workflow_dispatch: | |
| jobs: | |
| build-php72: | |
| permissions: | |
| packages: write | |
| strategy: | |
| matrix: | |
| arch: [ 'amd64', 'arm64' ] | |
| runs-on: "ubuntu-24.04${{ matrix.arch == 'arm64' && '-arm' || '' }}" | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.repository_owner }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and push | |
| uses: docker/build-push-action@v6 | |
| id: build | |
| with: | |
| context: ./php72-apache2 | |
| platforms: "linux/${{ matrix.arch }}" | |
| push: "${{ github.ref == 'refs/heads/main' }}" | |
| tags: "ghcr.io/openconext/openconext-basecontainers/php72-apache2" | |
| outputs: "type=image,push-by-digest=true,name-canonical=true" | |
| cache-from: type=gha,scope=buildkit-${{ matrix.arch }} | |
| cache-to: type=gha,scope=buildkit-${{ matrix.arch }} | |
| - name: Export digest | |
| run: | | |
| mkdir -p "${{ runner.temp }}/digests/" | |
| digest="${{ steps.build.outputs.digest }}" | |
| touch "${{ runner.temp }}/digests/${digest#sha256:}" | |
| echo "Files created:" | |
| find "${{ runner.temp }}/digests" | |
| - name: Upload digest | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: "digests__${{ env.NAME }}__${{ matrix.arch }}" | |
| path: "${{ runner.temp }}/digests/*" | |
| if-no-files-found: error | |
| retention-days: 1 | |
| image-php72: | |
| name: Merge images | |
| if: > | |
| github.actor!='dependabot[bot]' && | |
| github.event_name!='pull_request' && | |
| github.ref == 'refs/heads/main' | |
| needs: | |
| - "build-php72" | |
| runs-on: "ubuntu-24.04" | |
| steps: | |
| - name: Download digests | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: "${{ runner.temp }}/digests" | |
| pattern: "digests__*" | |
| merge-multiple: true | |
| - name: Log in to the Container registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: "${{ github.actor }}" | |
| password: "${{ secrets.GITHUB_TOKEN }}" | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Create manifest list and push | |
| working-directory: "${{ runner.temp }}/digests/" | |
| run: | | |
| DIGESTS=$( printf 'ghcr.io/openconext/openconext-basecontainers/php72-apache2@sha256:%s ' * ) | |
| TAGS="-t ghcr.io/openconext/openconext-basecontainers/php72-apache2:${{ github.sha }}" | |
| if [ "${{ github.ref }}" = "refs/heads/main" ]; then | |
| TAGS="${TAGS} -t ghcr.io/openconext/openconext-basecontainers/php72-apache2:latest" | |
| fi | |
| echo "Creating docker manifest list" | |
| echo "Digests: $DIGESTS" | |
| echo "Tags: $TAGS" | |
| docker buildx imagetools create ${TAGS} ${DIGESTS} | |
| - name: Inspect image | |
| run: | | |
| docker buildx imagetools inspect ghcr.io/openconext/openconext-basecontainers/php72-apache2:latest |