Replies: 1 comment
-
|
💬 Your Product Feedback Has Been Submitted 🎉 Thank you for taking the time to share your insights with us! Your feedback is invaluable as we build a better GitHub experience for all our users. Here's what you can expect moving forward ⏩
Where to look to see what's shipping 👀
What you can do in the meantime 💻
As a member of the GitHub community, your participation is essential. While we can't promise that every suggestion will be implemented, we want to emphasize that your feedback is instrumental in guiding our decisions and priorities. Thank you once again for your contribution to making GitHub even better! We're grateful for your ongoing support and collaboration in shaping the future of our platform. ⭐ |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
GitHub Actions: Duplicate Workflow Runs on PR Branches (Feature Request)
Summary
When a branch has an open pull request and receives a push, GitHub Actions triggers workflows twice - once for the
pushevent and once for thepull_requestsynchronize event. There is no clean way to prevent this duplication, leading to wasted CI resources and execution time.Problem Statement
Current Behavior
Consider a typical CI workflow configuration:
Scenario:
feature-xand pushes commitsfeature-xtomainfeature-xpushevent (because branch matches**)pull_requestsynchronize event (because PR exists)Real-World Impact
In our project (ApraPipes), we have 7 CI workflows covering different platforms:
Each PR commit triggers 14 workflow runs instead of 7 - a 100% waste of:
Average CI time per platform: 2 hours
Wasted time per PR commit: 14 hours of duplicate compute
Why Current Solutions Don't Work
1. Concurrency Groups
Attempted Solution:
Why it fails:
The
pushandpull_requestevents have different context variables, making it impossible to create identical group identifiers:github.head_refgithub.refpush""(empty)refs/heads/feature-xCI-refs/heads/feature-xpull_requestfeature-xrefs/pull/123/mergeCI-feature-xDifferent groups = Both runs execute in parallel
Even using
github.run_idas fallback doesn't help - each event gets a unique run ID, so they never share a group.2. Conditional Job Execution
Attempted Solution:
Why it fails:
The
github.event.pull_requestobject is only populated duringpull_requestevents. Duringpushevents, it'snulleven if a PR exists for that branch. There's no built-in way to check "does this pushed branch have an open PR?"3. Restricting Push Triggers
Attempted Solution:
Why it's inadequate:
This prevents duplication but breaks developer workflow:
4. GitHub API Check (Workaround)
Possible but painful:
Problems:
Proposed Solutions
Option A: New Event Filter (Preferred)
Add a built-in event filter to skip
pushwhen PR exists:Benefits:
Option B: Enhanced Context Variables
Make PR detection available in
pushevent context:Add to
pushevents:github.push.has_open_pull_request(boolean)github.push.pull_request_number(number or null)Option C: Smarter Concurrency Groups
Automatically unify concurrency groups across related events:
Where
github.branchresolves to the same value for both:pushtofeature-x→feature-xpull_requestfromfeature-x→feature-xCurrently impossible because
github.refdiffers between event types.Use Cases
This affects any project that wants:
push(before PR creation)pull_requesteventThis is a fundamental CI/CD pattern used across the industry (Jenkins, GitLab CI, CircleCI all handle this better).
Comparison with Other CI Systems
GitLab CI
Provides explicit control over when pipelines run based on MR existence.
CircleCI
Workflows automatically de-duplicate when both
pushandpull_requestwould trigger.Jenkins (GitHub Branch Source Plugin)
Provides
Discover pull requests from origin > Only pull requestsvsBoth pull requests and branchesoptions with smart de-duplication.Community Impact
Searching GitHub:
pushandpull_requesttriggerspush: branches: ["**"](breaks pre-PR validation)This is a well-known pain point affecting thousands of projects.
Conclusion
GitHub Actions needs a first-class solution for preventing duplicate
push/pull_requestruns. The current workarounds are:pushtriggers)None of these are acceptable for production CI/CD at scale.
Request: Please prioritize adding one of the proposed solutions (preferably Option A:
skip-if-pull-requestfilter) to make GitHub Actions competitive with other CI systems in this fundamental use case.Environment:
pushandpull_requesttriggersExample Repository: https://github.com/Apra-Labs/ApraPipes/tree/main/.github/workflows
Thank you for considering this improvement to GitHub Actions.
Beta Was this translation helpful? Give feedback.
All reactions