Skip to content

Fix issue #3

Fix issue #3 #24

Workflow file for this run

---
name: Image Release to GitHub Container Registry
on:
# Run the workflow every two sundays at 8:00 UTC
schedule:
- cron: "0 8 */14 * 0"
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# Trigger the workflow on new releases
release:
types: [published]
# Trigger the workflow on push or pull request when the
# Dockerfile is updated or the dependencies are updated
pull_request:
branches: [main]
paths:
- Dockerfile
- requirements.lock
- pyproject.toml
- src/dns_synchub/dns_synchub/__about__.py
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
attestations: write
packages: write
steps:
- name: Checkout the repository
uses: actions/checkout@v4
- name: Set up QEMU to build multi-platform images
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract version from src/dns_synchub/__about__.py
id: extract_version
run: |
VERSION=$(grep -Po '(?<=^__version__ = ")[^"]*' src/dns_synchub/__about__.py)
echo "VERSION=$VERSION" >> "$GITHUB_ENV"
shell: bash
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: |
name=${{ env.IMAGE_NAME }}
name=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}},value=${{ env.VERSION }}
- name: Build and Push image
id: push
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
push: ${{ !env.ACT && github.event_name != 'pull_request' }}
# Skip step because unsupported env variable: ACTIONS_ID_TOKEN_REQUEST_URL
# See https://github.com/nektos/act/issues/329
- name: Generate artifact attestation
uses: actions/attest-build-provenance@v1
if: ${{ !env.ACT && github.event_name != 'pull_request' }}
with:
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true