Fix Docker publish not triggering after GITHUB_TOKEN-merged PRs #220

Merged
admin-backup merged 2 commits from copilot/publish-image-on-each-commit into main 2026-03-23 23:51:03 +01:00
admin-backup commented 2026-03-23 23:41:42 +01:00 (Migrated from 172.24.0.1:8928)

When dependabot-auto-merge merges a PR using GITHUB_TOKEN, GitHub suppresses the resulting push event on main — so docker-build-push.yml never fires. This explains why Docker publishes stopped after the auto-merge workflow was introduced.

Changes

  • docker-build-push.yml: Add pull_request: types: [closed] trigger — the pull_request closed event is fired by GitHub's infrastructure regardless of who performed the merge, bypassing the GITHUB_TOKEN push-suppression
  • Add job-level if guard to skip PRs that were closed without merging
on:
    push:
        branches: [main]
    pull_request:
        branches: [main]
        types: [closed]        # fires even when merged via GITHUB_TOKEN

jobs:
    build-and-push:
        if: github.event_name != 'pull_request' || github.event.pull_request.merged == true

⚡ Quickly spin up Copilot coding agent tasks from anywhere on your macOS or Windows machine with Raycast.

When `dependabot-auto-merge` merges a PR using `GITHUB_TOKEN`, GitHub suppresses the resulting `push` event on `main` — so `docker-build-push.yml` never fires. This explains why Docker publishes stopped after the auto-merge workflow was introduced. ## Changes - **`docker-build-push.yml`**: Add `pull_request: types: [closed]` trigger — the `pull_request` closed event is fired by GitHub's infrastructure regardless of who performed the merge, bypassing the `GITHUB_TOKEN` push-suppression - Add job-level `if` guard to skip PRs that were closed without merging ```yaml on: push: branches: [main] pull_request: branches: [main] types: [closed] # fires even when merged via GITHUB_TOKEN jobs: build-and-push: if: github.event_name != 'pull_request' || github.event.pull_request.merged == true ``` <!-- START COPILOT CODING AGENT TIPS --> --- ⚡ Quickly spin up Copilot coding agent tasks from anywhere on your macOS or Windows machine with [Raycast](https://gh.io/cca-raycast-docs).
admin-backup commented 2026-03-23 23:41:42 +01:00 (Migrated from 172.24.0.1:8928)

assigned to @Copilot

assigned to `@Copilot`
admin-backup commented 2026-03-23 23:41:42 +01:00 (Migrated from 172.24.0.1:8928)

assigned to @THoguet

assigned to `@THoguet`
admin-backup commented 2026-03-23 23:44:59 +01:00 (Migrated from 172.24.0.1:8928)

changed title from {-[WIP] Add-} image publish{-ing-} on {-commits and PR merges to main-} to {+Verify: Docker+} image publish on {+every main push/merge is already implemented+}

changed title from **{-[WIP] Add-} image publish{-ing-} on {-commits and PR merges to main-}** to **{+Verify: Docker+} image publish on {+every main push/merge is already implemented+}**
admin-backup commented 2026-03-23 23:45:05 +01:00 (Migrated from 172.24.0.1:8928)

requested review from @THoguet

requested review from `@THoguet`
admin-backup commented 2026-03-23 23:49:54 +01:00 (Migrated from 172.24.0.1:8928)

changed title from {-Verify:-} Docker {-image -}publish {-on every main push/merge is already implemented-} to {+Fix+} Docker publish {+not triggering after GITHUB_TOKEN-merged PRs+}

changed title from **{-Verify:-} Docker {-image -}publish {-on every main push/merge is already implemented-}** to **{+Fix+} Docker publish {+not triggering after GITHUB_TOKEN-merged PRs+}**
admin-backup commented 2026-03-23 23:51:00 +01:00 (Migrated from 172.24.0.1:8928)

requested review from @Copilot

requested review from `@Copilot`
admin-backup commented 2026-03-23 23:51:03 +01:00 (Migrated from 172.24.0.1:8928)

Merged by: THoguet at 2026-03-23 22:51:03 UTC

*Merged by: THoguet at 2026-03-23 22:51:03 UTC*
admin-backup (Migrated from 172.24.0.1:8928) closed this pull request 2026-03-23 23:51:03 +01:00
admin-backup (Migrated from 172.24.0.1:8928) merged commit into main 2026-03-23 23:51:03 +01:00
admin-backup commented 2026-03-23 23:54:07 +01:00 (Migrated from 172.24.0.1:8928)

With the new pull_request (closed) execution path, the workflow’s ref/sha context is no longer the main branch push. As written, actions/checkout will check out the PR ref by default and docker/metadata-action tag generation (type=ref,event=branch and enable={{is_default_branch}}) is likely to produce different tags than the push-to-main path (e.g., not updating the main/latest tags). This means the added trigger may still not publish the tags you expect for mainline builds.

To make the PR-closed path equivalent to the main push path, explicitly build from the merged commit on main (or github.event.pull_request.merge_commit_sha) and ensure metadata/tag computation targets main/default-branch tagging when the PR was merged into main.

With the new `pull_request` (closed) execution path, the workflow’s ref/sha context is no longer the `main` branch push. As written, `actions/checkout` will check out the PR ref by default and `docker/metadata-action` tag generation (`type=ref,event=branch` and `enable={{is_default_branch}}`) is likely to produce different tags than the `push`-to-`main` path (e.g., not updating the `main`/`latest` tags). This means the added trigger may still not publish the tags you expect for mainline builds. To make the PR-closed path equivalent to the main push path, explicitly build from the merged commit on `main` (or `github.event.pull_request.merge_commit_sha`) and ensure metadata/tag computation targets `main`/default-branch tagging when the PR was merged into `main`.
admin-backup commented 2026-03-23 23:54:07 +01:00 (Migrated from 172.24.0.1:8928)

Adding a pull_request: closed trigger alongside the existing push trigger will cause this workflow to run twice for typical manual merges into main (once on the push, once on pull_request closed+merged). That can double-build and double-push the same image and waste CI minutes (and can also create nondeterminism if both jobs race to push tags).

Consider narrowing the pull_request path to only the cases where push is suppressed (e.g., merges performed by github-actions[bot] / your auto-merge workflow), or add workflow/job concurrency keyed to the resulting main-branch commit so only one run publishes.

Adding a `pull_request: closed` trigger alongside the existing `push` trigger will cause this workflow to run twice for typical manual merges into `main` (once on the `push`, once on `pull_request` closed+merged). That can double-build and double-push the same image and waste CI minutes (and can also create nondeterminism if both jobs race to push tags). Consider narrowing the `pull_request` path to only the cases where `push` is suppressed (e.g., merges performed by `github-actions[bot]` / your auto-merge workflow), or add workflow/job concurrency keyed to the resulting main-branch commit so only one run publishes.
admin-backup commented 2026-03-23 23:54:07 +01:00 (Migrated from 172.24.0.1:8928)

Review: Commented

Pull request overview

This PR updates the Docker publish workflow to ensure Docker images are built and pushed even when merges are performed via GITHUB_TOKEN (which can suppress push events on main), by triggering on pull_request close events and gating execution to merged PRs.

Changes:

  • Add pull_request trigger for types: [closed] on main.
  • Add a job-level if condition to skip PRs that were closed without merging.
**Review:** Commented ## Pull request overview This PR updates the Docker publish workflow to ensure Docker images are built and pushed even when merges are performed via `GITHUB_TOKEN` (which can suppress `push` events on `main`), by triggering on `pull_request` close events and gating execution to merged PRs. **Changes:** - Add `pull_request` trigger for `types: [closed]` on `main`. - Add a job-level `if` condition to skip PRs that were closed without merging.

Preserved source assignment/reviewer metadata. Historical accounts stay inactive.

Source requested reviewers: admin-backup (GitLab user 3).

The linked history record retains original IDs and source dates. No historical identity was merged into nessar or granted new authentication permissions.

<!-- gitlab-to-gitea-assignment:35:MergeRequest:142 --> Preserved source assignment/reviewer metadata. Historical accounts stay inactive. Source requested reviewers: admin-backup (GitLab user 3). The linked history record retains original IDs and source dates. No historical identity was merged into nessar or granted new authentication permissions.

Preserved GitLab !142 history: source attribution, exact timestamps, discussion grouping and review positions. Historical diff snapshots: 1; visible source notes: 10.

gitlab-35-mergerequest-142.md (SHA-256 0817dc52a40b114d17562b12238077e3ec58bc9ac496b24f03408b4f5f593148)

gitlab-35-mergerequest-142.json (SHA-256 439acb453ffe2e060cd014675141bf028c5f0e1f4d5837660779b8a8d97fdcfe)

Old CI job execution and reports are omitted. Original source files and rollback backups remain protected.

<!-- gitlab-to-gitea-history:35:MergeRequest:142 --> Preserved GitLab !142 history: source attribution, exact timestamps, discussion grouping and review positions. Historical diff snapshots: 1; visible source notes: 10. [gitlab-35-mergerequest-142.md](https://gitea.nessar.fr/attachments/f083dd88-aadd-44a3-aa2e-270aa64c3212) (SHA-256 `0817dc52a40b114d17562b12238077e3ec58bc9ac496b24f03408b4f5f593148`) [gitlab-35-mergerequest-142.json](https://gitea.nessar.fr/attachments/8969bdab-7c92-47de-a021-6028b274a115) (SHA-256 `439acb453ffe2e060cd014675141bf028c5f0e1f4d5837660779b8a8d97fdcfe`) Old CI job execution and reports are omitted. Original source files and rollback backups remain protected.
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: nessar/vac-optimizer#220