Skip to content

BuildContainerForProduction #859

BuildContainerForProduction

BuildContainerForProduction #859

Workflow file for this run

name: BuildContainerForProduction
on:
workflow_dispatch:
push:
branches:
- master
schedule:
- cron: 00 4 * * 4
permissions:
contents: read
packages: write
jobs:
build:
runs-on: ubuntu-latest
name: Build Docker image
strategy:
matrix:
php:
- php7
- php8
steps:
- name: Shallow clone code
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Login to Container Registry ghcr.io
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }} # ghcr logins allow mixed case usernames
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build the container image
run: docker build . --tag "ghcr.io/$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]'):${{ matrix.php }}" --file Dockerfile.${{ matrix.php }}
- name: Push with commit ${{ matrix.php }} tag
run: docker push "ghcr.io/$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]'):${{ matrix.php }}"
#review containers
- name: Build the review container image
run: docker build . --tag "ghcr.io/$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]'):${{ matrix.php }}-review" --file Dockerfile.${{ matrix.php }}-review
- name: Push with commit *-review tag
run: docker push "ghcr.io/$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]'):${{ matrix.php }}-review"
cleanup:
needs: [build]
runs-on: ubuntu-latest
steps:
- name: Login to Container Registry ghcr.io
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }} #ghcr logins allow mixed case usernames
password: ${{ secrets.GITHUB_TOKEN }}
- name: Delete old versions of the package, keeping a few of the newest
uses: actions/delete-package-versions@v5
with:
package-name: ${{ github.event.repository.name }}
package-type: container
min-versions-to-keep: 8