Skip to content

Stop the Build workflow from running twice on same-repo PRs - #3311

Merged
dennisdoomen merged 1 commit into
fluentassertions:mainfrom
dennisdoomen:claude/github-actions-duplicate-pipelines-770dcd
Aug 16, 2026
Merged

dennisdoomen merged 1 commit into
fluentassertions:mainfrom
dennisdoomen:claude/github-actions-duplicate-pipelines-770dcd

Conversation

@dennisdoomen

@dennisdoomen dennisdoomen commented Aug 16, 2026

Copy link
Copy Markdown
Member

When a branch is pushed directly to this repo (not a fork) and a PR is then opened from it, the `Build` workflow was running twice for the exact same commit — once for the `push` event and once for the `pull_request` event — because it was declared as `on: [push, pull_request]` with no branch filter.

What changed

  • Restricted the `push` trigger in build.yml to `main`, `develop`, `support-*` (maintenance branches like `support-7.0` that also get direct pushes/backports), and tags (needed for the NuGet publish/attest steps gated on `refs/tags/` — this repo's release tags are bare semver like `8.10.0`, not `v`-prefixed). Topic/feature branches (which don't follow a consistent naming convention in this repo) no longer trigger a `push`-based run — only `pull_request` covers them.
  • Added a `concurrency` group (keyed by PR number, falling back to ref for plain pushes) with `cancel-in-progress: true`, so a stale run for the same branch/PR is cancelled when a newer one starts. Note: this doesn't dedupe the push-vs-pull_request case itself — that's handled by the branch restriction above — it just avoids piling up redundant runs within the same trigger type (e.g. rapid-fire pushes to `develop`, or repeated `synchronize` events on a PR).

Not touched

Reviewer notes

No public API, test, or documentation changes — this is CI configuration only.

🤖 Generated with Claude Code

Previously build.yml used `on: [push, pull_request]` with no branch
filter, so pushing a branch directly to this repo (not a fork) and
then opening a PR from it triggered both the push event and the
pull_request event for the same commit, running the full build
matrix twice.

Restrict `push` to main, develop, support-* (maintenance branches
like support-7.0 that also get direct pushes/backports), and tags
(needed for the NuGet publish/attest steps gated on refs/tags/ --
this repo's release tags are bare semver like 8.10.0, not
v-prefixed) so topic branches only trigger via pull_request.

Also add a concurrency group so a stale run for the same branch/PR
is cancelled when a newer one starts.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@dennisdoomen
dennisdoomen force-pushed the claude/github-actions-duplicate-pipelines-770dcd branch from 0600b77 to 4dfa2b1 Compare August 16, 2026 07:12
@github-actions

Copy link
Copy Markdown

Qodana for .NET

It seems all right 👌

No new problems were found according to the checks applied

💡 Qodana analysis was run in the pull request mode: only the changed files were checked
☁️ View the detailed Qodana report

Contact Qodana team

Contact us at qodana-support@jetbrains.com

@dennisdoomen
dennisdoomen merged commit 0d176bb into fluentassertions:main Aug 16, 2026
4 checks passed
This was referenced Sep 14, 2026
This was referenced Sep 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants