Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce duplicate GitHub Action runs #2858

Merged
merged 3 commits into from
Nov 23, 2023
Merged

Reduce duplicate GitHub Action runs #2858

merged 3 commits into from
Nov 23, 2023

Conversation

danyeaw
Copy link
Member

@danyeaw danyeaw commented Nov 21, 2023

Currently, when pushing a branch and opening a PR, GitHub Actions runs two complete builds. This PR tries to reduce duplicate runs by only running the full build when:

  1. A PR is opened against the main branch
  2. Push to the main branch
  3. On release
  4. On manually trigger a build with workflow dispatch from the actions menu

The tradeoff of this will be that if you want to run GitHub Actions, you'll need to open a draft PR or manually start it from the Actions tab, since pushing to a branch will not start a run.

I also added logic to cancel running previous workflows using concurrency.

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bug fix
  • Feature
  • Chore (refactoring, formatting, local variables, other cleanup)
  • Documentation content changes

What is the current behavior?

2 full builds for each push of a PR

Issue Number: N/A

What is the new behavior?

Avoid duplicate builds under most circumstances

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@danyeaw danyeaw added the chore Maintenance related PR label Nov 21, 2023
@amolenaar
Copy link
Member

I like the ability to run a pipeline before I create a PR. But I agree that building for both pull and PR is overhead we can do without.

How does it work for forks? Should they open a PR in order to build something?

@danyeaw
Copy link
Member Author

danyeaw commented Nov 21, 2023

I like the ability to run a pipeline before I create a PR. But I agree that building for both pull and PR is overhead we can do without.

I think the workflow dispatch would help fill in this use case by manually running a workflow by selecting the branch you push.

How does it work for forks? Should they open a PR in order to build something?

Yup, create a PR.

@amolenaar
Copy link
Member

I like the ability to run a pipeline before I create a PR. But I agree that building for both pull and PR is overhead we can do without.

I think the workflow dispatch would help fill in this use case by manually running a workflow by selecting the branch you push.

Fair enough. That's an option indeed.

How does it work for forks? Should they open a PR in order to build something?

Yup, create a PR.

This implies they cannot check if all builds, unless a build id triggered manually. Which is fine, I suppose.

@danyeaw danyeaw merged commit 77b8e1f into main Nov 23, 2023
31 checks passed
@danyeaw danyeaw deleted the reduce-duplicate-CICD branch November 23, 2023 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore Maintenance related PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants