Skip to content

ci: restrict to only tag-based triggers #8

ci: restrict to only tag-based triggers

ci: restrict to only tag-based triggers #8

Workflow file for this run

name: Build and Publish Docker image to GHCR
on:
push:
tags: ["v*.*.*"]
workflow_dispatch:
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
# Checkout source code
- name: Checkout repository
uses: actions/checkout@v4
# Set up emulation for multi-arch builds
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
# Set up Buildx
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# Convert repository owner to lowercase (required for GHCR image names)
- name: Set lowercase repository owner
id: repo_owner
run: echo "lowercase=$(echo ${GITHUB_REPOSITORY_OWNER} | tr '[:upper:]' '[:lower:]')" >> "$GITHUB_OUTPUT"
# Log in to GitHub Container Registry using the auto-generated token
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Derive image metadata (tags & labels)
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ steps.repo_owner.outputs.lowercase }}/wireport
# Build and push the image defined in wireport/Dockerfile
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: ./
file: ./Dockerfile
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=ghcr.io/${{ steps.repo_owner.outputs.lowercase }}/wireport:buildcache
cache-to: type=registry,ref=ghcr.io/${{ steps.repo_owner.outputs.lowercase }}/wireport:buildcache,mode=max