`Development`: Use existing builds for protected branches and improve PR lookup to avoid forked PR interference
Motivation and Context
Our previous deployment logic had two key issues:
-
Redundant builds for protected branches
When deploying protected branches like
developormain, which rely on thepushevent to triggerbuild.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 targetingdevelop. If a user had opened a PR from a fork (e.g., their forked repo’sdevelopbranch), 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
-
developbranch deployment: https://github.com/ls1intum/Artemis/actions/runs/14591912614 - Branch without PR deployment: https://github.com/ls1intum/Artemis/actions/runs/14592440623
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.
@Hialus @bensofficial Can you take a look at this?
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.
Hello @Hialus, could you also take a look at and also maybe run some deployments to test the functionality?
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 👍🏻
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.
@Hialus could you please take a look at this PR?
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.
Hey @Hialus do you have a time to check the latest changes?