simonkowallik/tmconfpy

View on GitHub
.github/workflows/release-container.yaml

Summary

Maintainability
Test Coverage
name: Release Container Image
  
on:
  workflow_dispatch:
  release:
    types: [released]

jobs:
  release-container-image:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      packages: write
      id-token: write
      attestations: write
    steps:
      - name: Checkout
        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: Login to Docker Hub
        uses: docker/login-action@v3
        with:
          username: ${{ secrets.DOCKERHUB_USERNAME }}
          password: ${{ secrets.DOCKERHUB_TOKEN }}

      - name: Login to GitHub Container Registry
        uses: docker/login-action@v3
        with:
          registry: ghcr.io
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}

      - name: Extract metadata (tags, labels)
        id: metadata
        uses: docker/metadata-action@v5
        with:
          images: |
              ${{ github.repository }}
              ghcr.io/${{ github.repository }}
          tags: |
            type=raw,value=latest,enable={{is_default_branch}}
            type=schedule,pattern={{date 'YYYYMMDD-HHmmss' tz='UTC'}}
            type=ref,event=branch
            type=ref,event=pr
            type=pep440,pattern={{major}}.{{minor}}.{{patch}}
            type=pep440,pattern={{version}}
            type=pep440,pattern={{major}}
            type=sha
      - name: Build and push
        id: push
        uses: docker/build-push-action@v6
        with:
          context: .
          platforms: linux/amd64,linux/arm64
          file: Dockerfile
          push: true
          cache-from: type=gha
          cache-to: type=gha,mode=max
          tags: ${{ steps.metadata.outputs.tags }}
          labels: ${{ steps.metadata.outputs.labels }}

      - name: Generate artifact attestation
        uses: actions/attest-build-provenance@v1
        with:
          subject-name: ghcr.io/${{ github.repository }}
          subject-digest: ${{ steps.push.outputs.digest }}
          push-to-registry: true
          
      - name: Docker Hub Description
        uses: peter-evans/dockerhub-description@v4
        with:
          # docker... https://github.com/peter-evans/dockerhub-description/issues/10
          username: ${{ secrets.DOCKERHUB_USERNAME }}
          password: ${{ secrets.DOCKERHUB_PASSWORD }}
          repository: ${{ github.repository }}
          short-description: ${{ github.event.repository.description }}