Workflow file for this run
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: Create and publish a Docker images to GHCR | |
on: | |
push: | |
paths: | |
- ".github/workflows/docker.yml" | |
- "nginx/**" | |
- "worker/**" | |
workflow_dispatch: | |
pull_request: | |
branches: [ "main" ] | |
paths: | |
- ".github/workflows/docker.yml" | |
- "nginx/**" | |
- "worker/**" | |
env: | |
REGISTRY: ghcr.io | |
PLATFORMS: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6,linux/386,linux/ppc64le,linux/s390x | |
jobs: | |
build: | |
name: Build for ${{ matrix.context }} | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- dockerfile: ./worker/Dockerfile | |
context: worker | |
image: ${{ github.repository }}-worker | |
- dockerfile: ./nginx/Dockerfile | |
context: nginx | |
image: ${{ github.repository }}-nginx | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Log into registry ${{ env.REGISTRY }} | |
if: github.event_name != 'pull_request' | |
uses: docker/[email protected] | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract Docker metadata | |
id: meta | |
uses: docker/[email protected] | |
with: | |
images: ${{ env.REGISTRY }}/${{ matrix.image }} | |
tags: | | |
type=raw,value=latest,enable={{is_default_branch}} | |
type=sha,prefix={{branch}}- | |
type=ref,event=branch | |
- name: Build and push Docker image | |
id: build-and-push | |
uses: docker/[email protected] | |
with: | |
context: ${{ matrix.context }} | |
provenance: false | |
platforms: ${{ env.PLATFORMS }} | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max |