oxipng/.github/workflows/docker.yml
vlakoff 4f0bb03680
Isolate merge_group concurrency to prevent race conditions
Implement a prefix-based concurrency group to ensure GitHub Merge Queue
events are not prematurely cancelled by simultaneous push events.

- Use 'mq-' prefix in concurrency keys for merge_group events to create
  isolated groups distinct from standard push events.
- Maintain PR number in keys to allow synchronize events to cancel
  stale runs, preserving CI efficiency.
- Simplify job filters to skip redundant push runs on internal merge
  queue branches.
2026-04-30 08:26:54 +02:00

66 lines
2.1 KiB
YAML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

name: docker
on:
push:
branches:
- 'master'
tags:
- 'v*.*.*'
pull_request:
merge_group:
types:
- checks_requested
workflow_dispatch:
inputs:
use_cache:
description: "Use build cache"
required: true
type: boolean
default: true
concurrency:
group: >-
${{ github.workflow }}-
${{ github.event.pull_request.number ||
(github.event_name == 'merge_group' && format('mq-{0}', github.event.merge_group.head_ref)) ||
github.ref }}
cancel-in-progress: true
jobs:
build:
uses: docker/github-builder/.github/workflows/build.yml@v1
# Exclude 'push' events on Merge Queue branches, as they are already
# handled by the 'merge_group' event.
if: (!(github.event_name == 'push' && startsWith(github.ref, 'refs/heads/gh-readonly-queue/')))
permissions:
contents: read
packages: write
id-token: write
attestations: write
with:
context: . # Use local checkout to support GitHub Merge Queue
output: image
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
cache: ${{ github.event_name != 'workflow_dispatch' || inputs.use_cache }}
# We don't sign the image because ghcr.io doesn't support OCI Referrers API yet, and the fallback relies on pushing new tags on each build
# https://github.com/docker/github-builder/issues/109#issuecomment-3885082486
# https://github.com/opencontainers/distribution-spec/blob/v1.1.0/spec.md#backwards-compatibility
sign: false
sbom: true
meta-images: ghcr.io/${{ github.repository }}
meta-tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{raw}}
set-meta-annotations: true
set-meta-labels: true
labels: |
org.opencontainers.image.title=Oxipng
annotations: |
org.opencontainers.image.title=Oxipng
secrets:
registry-auths: |
- registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}