Artemis icon indicating copy to clipboard operation
Artemis copied to clipboard

`Development`: Use existing builds for protected branches and improve PR lookup to avoid forked PR interference

Open egekocabas opened this issue 1 year ago • 7 comments

Motivation and Context

Our previous deployment logic had two key issues:

  • Redundant builds for protected branches When deploying protected branches like develop or main, which rely on the push event to trigger build.yml, we unnecessarily triggered a new build even when a successful one already existed. This led to wasted CI resources and longer deployment times.
  • Incorrect PR detection due to forked repositories When attempting to deploy a branch (e.g., develop), the workflow searched for any open PRs targeting develop. If a user had opened a PR from a fork (e.g., their forked repo’s develop branch), it matched the search query, leading to misaligned deployment behavior.

This PR addresses both issues by:

  • Checking for existing successful builds for protected branches and reusing them when available.
  • Updating PR lookup logic to only consider internal PRs (i.e., those where the source and target repos match), avoiding interference from forked repositories.

Description

  • Added a filter in the PR lookup logic to ensure only internal PRs (non-forked) are considered during deployment checks.
  • Introduced a mechanism to detect and use existing successful builds for protected branches (develop, main), skipping unnecessary rebuilds.

Example Runs

  • PR deployment: https://github.com/ls1intum/Artemis/actions/runs/14592286069
  • develop branch deployment: https://github.com/ls1intum/Artemis/actions/runs/14591912614
  • Branch without PR deployment: https://github.com/ls1intum/Artemis/actions/runs/14592440623

egekocabas avatar Apr 22 '25 08:04 egekocabas

There hasn't been any activity on this pull request recently. Therefore, this pull request has been automatically marked as stale and will be closed if no further activity occurs within seven days. Thank you for your contributions.

github-actions[bot] avatar Apr 29 '25 12:04 github-actions[bot]

@Hialus @bensofficial Can you take a look at this?

Mtze avatar Apr 30 '25 15:04 Mtze

There hasn't been any activity on this pull request recently. Therefore, this pull request has been automatically marked as stale and will be closed if no further activity occurs within seven days. Thank you for your contributions.

github-actions[bot] avatar May 19 '25 12:05 github-actions[bot]

Hello @Hialus, could you also take a look at and also maybe run some deployments to test the functionality?

egekocabas avatar May 19 '25 15:05 egekocabas

Logic seems good to me. However, I am not a fan of naming the new logic "is_main_branch" and "for main branch", as it also applies to the develop branch. It'd be better IMO if you'd name this in a way that removes this confusion.

Renamed it to is_main_or_develop which gives clarity 👍🏻

egekocabas avatar May 28 '25 18:05 egekocabas

There hasn't been any activity on this pull request recently. Therefore, this pull request has been automatically marked as stale and will be closed if no further activity occurs within seven days. Thank you for your contributions.

github-actions[bot] avatar Jun 05 '25 12:06 github-actions[bot]

@Hialus could you please take a look at this PR?

egekocabas avatar Jun 13 '25 19:06 egekocabas

There hasn't been any activity on this pull request recently. Therefore, this pull request has been automatically marked as stale and will be closed if no further activity occurs within seven days. Thank you for your contributions.

github-actions[bot] avatar Jun 21 '25 12:06 github-actions[bot]

Hey @Hialus do you have a time to check the latest changes?

egekocabas avatar Jun 21 '25 20:06 egekocabas