# GitLab !142: Fix Docker publish not triggering after GITHUB_TOKEN-merged PRs Original: `nessar/vac-optimizer`; GitLab MergeRequest ID 198. Target: [#220](https://gitea.nessar.fr/nessar/vac-optimizer/pulls/220). Author: admin-backup (GitLab user 3). Created: 2026-03-23T22:41:42.000Z. Last source update: 2026-03-23T22:54:07.000Z. Source state: merged; discussion locked: False. This linked record preserves source attribution, timestamps, discussion grouping, review positions and historical diffs. Current Gitea activity is separate from the original source dates. Old CI jobs and their reports are omitted by owner decision. Source requested reviewers: admin-backup (GitLab user 3). ## Discussions and activity ### Discussion a634bb8210cc0b5bd9571b3d640a238b17d65c31 #### Source note 668 — admin-backup (GitLab user 3) — 2026-03-23T22:41:42Z system activity. ````text assigned to `@Copilot` ```` ### Discussion f6220398a9b21bc59e5f6dabac11649e236a0128 #### Source note 669 — admin-backup (GitLab user 3) — 2026-03-23T22:41:42Z system activity. ````text assigned to `@THoguet` ```` ### Discussion 15343041d26fd5895ee843f737c90e06f92ae70c #### Source note 671 — admin-backup (GitLab user 3) — 2026-03-23T22:44:59Z system activity. ````text 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+}** ```` ### Discussion 4bd32c87042ef0698c9998d886eef40d16bb7740 #### Source note 670 — admin-backup (GitLab user 3) — 2026-03-23T22:45:05Z system activity. ````text requested review from `@THoguet` ```` ### Discussion 5137d9b43efc2b6b9e7d3c0d0db4c524e3152d1e #### Source note 673 — admin-backup (GitLab user 3) — 2026-03-23T22:49:54Z system activity. ````text 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+}** ```` ### Discussion d99d6eb8bea34117ce57c0299df304ce16f292db #### Source note 672 — admin-backup (GitLab user 3) — 2026-03-23T22:51:00Z system activity. ````text requested review from `@Copilot` ```` ### Discussion ede88028e784b7d1f92e67fd7f7da5a8cc79cb81 #### Source note 674 — admin-backup (GitLab user 3) — 2026-03-23T22:51:03Z ````text *Merged by: THoguet at 2026-03-23 22:51:03 UTC* ```` ### Discussion 49b4cb3892fa5197b086a0b167fb19838d7e8f9f #### Source note 337 — admin-backup (GitLab user 3) — 2026-03-23T22:54:07Z LegacyDiffNote; unresolved. Source review position: ```json { "position": null, "original_position": null, "line_code": "82df5c585f916d6efd49917388cc6ccf97190faa_12_15" } ``` ````text 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`. ```` ### Discussion 6971a6901ca73baa6e8c17c8d661add7102999c9 #### Source note 339 — admin-backup (GitLab user 3) — 2026-03-23T22:54:07Z LegacyDiffNote; unresolved. Source review position: ```json { "position": null, "original_position": null, "line_code": "82df5c585f916d6efd49917388cc6ccf97190faa_6_8" } ``` ````text 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. ```` ### Discussion 10bc0ed7af6aaf3f263a4dec3be35ec6108d1b06 #### Source note 675 — admin-backup (GitLab user 3) — 2026-03-23T22:54:07Z ````text **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. ```` ## State event records - {"close_after_error_tracking_resolve": false, "close_auto_resolve_prometheus_alert": false, "created_at": "2026-03-23T22:51:03+00:00", "epic_id": null, "id": 395, "imported_from": 4, "issue_id": null, "merge_request_id": 198, "namespace_id": 38, "source_commit": null, "source_merge_request_id": null, "state": 2, "user_id": 3} - {"close_after_error_tracking_resolve": false, "close_auto_resolve_prometheus_alert": false, "created_at": "2026-03-23T22:51:03+00:00", "epic_id": null, "id": 397, "imported_from": 4, "issue_id": null, "merge_request_id": 198, "namespace_id": 38, "source_commit": "cb5f440d0215df2944737f28cbb7311fab42c8f0", "source_merge_request_id": null, "state": 3, "user_id": 3} ## Historical diff versions ### Diff version 198 — 2026-05-03T16:00:26.273236Z Base `257ccab43d6d2f1fd55951318f39d83c94c8ecdb`; start `257ccab43d6d2f1fd55951318f39d83c94c8ecdb`; head `38445ad11d3a35fea2472eb5b57f4741cb3a591c`. Files: 1; stored commits: 2. #### `.github/workflows/docker-build-push.yml` → `None` Modes 100644 → 100644; new=False, deleted=False, renamed=False, binary=False, too_large=False. ````diff @@ -3,12 +3,16 @@ name: Docker Build and Push on: push: branches: [main] + pull_request: + branches: [main] + types: [closed] release: types: [published] workflow_dispatch: jobs: build-and-push: + if: github.event_name != 'pull_request' || github.event.pull_request.merged == true runs-on: ubuntu-latest permissions: contents: read ````