Docker #48
This file contains 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: 'Docker' | |
on: | |
schedule: | |
- cron: "0 0 * * 0" | |
push: | |
branches: [ main ] | |
pull_request: | |
jobs: | |
matrix: | |
runs-on: ubuntu-latest | |
name: 'Matrix' | |
steps: | |
- name: 'Checkout repository' | |
uses: actions/checkout@v4 | |
- name: 'Setup PHP' | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: 8.1 | |
- name: 'Load configurations' | |
id: configurations | |
working-directory: scripts | |
run: echo "configurations=$(php configurations.php)" >> $GITHUB_OUTPUT | |
outputs: | |
configurations: ${{ steps.configurations.outputs.configurations }} | |
dockerfile: | |
needs: matrix | |
runs-on: ubuntu-latest | |
name: 'Dockerfile.${{ matrix.configuration }}' | |
strategy: | |
matrix: | |
configuration: ${{ fromJson(needs.matrix.outputs.configurations) }} | |
steps: | |
- name: 'Checkout repository' | |
uses: actions/checkout@v4 | |
- name: Store repo name and owner in lower case | |
shell: bash | |
run: echo "LOWER_CASE_REPO_NAME=$(echo ${GITHUB_REPOSITORY} | tr /A-Z/ /a-z/)" >> $GITHUB_ENV | |
- name: 'Setup PHP' | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: 8.1 | |
- name: 'Generate Dockerfile' | |
working-directory: scripts | |
run: php generate.php ${{ matrix.configuration }} | |
- name: 'Upload Dockerfile' | |
uses: actions/upload-artifact@v3 | |
with: | |
name: Dockerfile.${{ matrix.configuration }} | |
path: Dockerfile | |
- name: 'Set up Docker QEMU' | |
uses: docker/setup-qemu-action@v3 | |
- name: 'Setup Docker buildx' | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Docker registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: 'Extract Docker metadata' | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.LOWER_CASE_REPO_NAME }} | |
tags: | | |
type=raw,value=${{ matrix.configuration }} | |
- name: Build and push | |
uses: docker/[email protected] | |
with: | |
platforms: linux/arm64,linux/amd64 | |
context: . | |
# Only releases or pushes to development or main branch | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: ghcr.io/${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
# Use GitHub Actions cache | |
cache-from: type=gha | |
cache-to: type=gha,mode=max |