2.0 KiB · text History 920fa72
# The forge's copy of the image publish. .github/workflows/ci.yml's
# image job pushes to ghcr.io (and the other public registries), but only
# when it runs on GitHub; here the image goes to the forge's bundled
# registry (CI_REGISTRY), as camerite and gitgud do: <registry>/<owner>/<repo>.
#
# No secrets. The forge injects CI_REGISTRY and accepts the per-job
# github.token for push to this repository's own image path.
#
# No test gate: this workflow can't `needs:` ci.yml's test job (mix precommit),
# and the Dockerfile compiles the release itself.
name: image

on:
  push:
    branches: [master]
    tags: ['v*']
  workflow_dispatch:

jobs:
  image:
    if: github.server_url != 'https://github.com'
    runs-on: arc-runner-set
    permissions:
      contents: read
      packages: write
    steps:
      - uses: actions/checkout@v4
      - uses: docker/setup-buildx-action@v3

      # The username is ignored by the token endpoint, but login-action
      # requires it to be non-empty.
      - name: Log in to the forge registry
        uses: docker/login-action@v3
        with:
          registry: ${{ vars.CI_REGISTRY }}
          username: gitgud-actions
          password: ${{ github.token }}

      - id: meta
        uses: docker/metadata-action@v5
        with:
          images: ${{ vars.CI_REGISTRY }}/${{ github.repository }}
          tags: |
            type=ref,event=branch
            type=semver,pattern={{version}}
            type=semver,pattern={{major}}.{{minor}}
            type=sha
            type=raw,value=latest,enable={{is_default_branch}}

      - uses: docker/build-push-action@v6
        with:
          context: .
          platforms: linux/amd64
          push: true
          tags: ${{ steps.meta.outputs.tags }}
          labels: ${{ steps.meta.outputs.labels }}
          cache-from: type=registry,ref=${{ vars.CI_REGISTRY }}/${{ github.repository }}:buildcache
          cache-to: type=registry,ref=${{ vars.CI_REGISTRY }}/${{ github.repository }}:buildcache,mode=max