2.0 KiB · text History 52a9112
# The forge's copy of the image publish. .github/workflows/
# docker-build-push.yml pushes to ghcr.io, 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>,
# tagged with the full commit sha and :latest like the ghcr.io one.
#
# No secrets. The forge injects CI_REGISTRY and accepts the per-job
# github.token for push to this repository's own image path.
name: image

on:
  push:
    branches: [master]
  workflow_dispatch:

# A newer push supersedes this run: on a branch or PR the run in
# progress is cancelled; on master it finishes, and only a run still
# waiting is replaced.
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}

jobs:
  image:
    if: github.server_url != 'https://github.com'
    runs-on: ubuntu-latest
    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=raw,value=${{ github.sha }}
            type=raw,value=latest,enable={{is_default_branch}}

      - uses: docker/build-push-action@v6
        with:
          context: .
          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