Skip to content

chore(ci): Avoid build twice the same commit on PR - #3708

Merged
jihuayu merged 3 commits into
apache:unstablefrom
apupier:AvoidBuildingSamePRChangeSeveralTime
Oct 22, 2026
Merged

jihuayu merged 3 commits into
apache:unstablefrom
apupier:AvoidBuildingSamePRChangeSeveralTime

Conversation

@apupier

@apupier apupier commented Oct 21, 2026

Copy link
Copy Markdown

A workflow with a push trigger and no branch filter fires on every commit pushed to any
branch. When the same workflow also has a pull_request trigger this causes it to run
twice for the same code — once for the PR and once for the push — wasting runner resources.

The fix is to add a branches (or branches-ignore) filter to the push trigger, e.g.:
on:
push:
branches:
- main pull_request:

Reference best practice:
https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=430408443#GitHubActionsRecommendedPractices-Restrictthepushtriggertospecificbranches

@github-actions

Copy link
Copy Markdown

Hi @apupier,

Thank you for your pull request. Please review our Contributing Guide.

Please make sure you understand your changes and explain your reasoning in this pull request. Low-quality pull requests may be closed.

@apupier

apupier commented Oct 21, 2026

Copy link
Copy Markdown
Author

for instance on this PR #3706 all CI jobs are duplicated, one time with push and one time pull_request trigger.

image

@jihuayu jihuayu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

Comment thread .github/workflows/kvrocks.yaml Outdated
Comment on lines +23 to +24
- 2.17
- 2.16

@jihuayu jihuayu Oct 21, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- 2.17
- 2.16
- '*.*'
- '*.*.*'
- 'action/**'

@apupier
apupier force-pushed the AvoidBuildingSamePRChangeSeveralTime branch 2 times, most recently from 3703171 to 29af762 Compare October 21, 2026 16:06
A workflow with a push trigger and no branch filter fires on every
commit pushed to any
branch.  When the same workflow also has a pull_request trigger this
causes it to run
twice for the same code — once for the PR and once for the push —
wasting runner resources.

The fix is to add a branches (or branches-ignore) filter to the push
trigger, e.g.:
    on:
      push:
        branches:
          - main
      pull_request:

Reference best practice:
  https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=430408443#GitHubActionsRecommendedPractices-Restrictthepushtriggertospecificbranches

Signed-off-by: Aurélien Pupier <apupier@ibm.com>
@apupier
apupier force-pushed the AvoidBuildingSamePRChangeSeveralTime branch from 29af762 to 8b4607c Compare October 21, 2026 16:07
@aleksraiden
aleksraiden enabled auto-merge (squash) October 21, 2026 17:46
@aleksraiden
aleksraiden disabled auto-merge October 21, 2026 17:47
@jihuayu
jihuayu enabled auto-merge (squash) October 22, 2026 02:09
@jihuayu
jihuayu merged commit e8b1d85 into apache:unstable Oct 22, 2026
71 of 74 checks passed
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.

5 participants