chore: add workflow to clean up stale test release branches and PRs#8501
Open
hectormmg wants to merge 9 commits into
Open
chore: add workflow to clean up stale test release branches and PRs#8501hectormmg wants to merge 9 commits into
hectormmg wants to merge 9 commits into
Conversation
Adds a scheduled GitHub Actions workflow that runs daily to close open PRs whose head branch matches a test-release-staging-* prefix and have been open for more than 7 days, then immediately deletes the branch. Also removes orphaned staging branches with no associated open PR. PRs are matched by head branch name only — never by title — so manually opened PRs are never affected. Covers both the main and v4-lts release pipelines since both use the same test-release-staging-<BuildId> naming convention. Branch prefix is driven by the TEST_BRANCH_PREFIXES repository variable (Settings → Actions → Variables) with a hardcoded fallback default, so naming conventions can be updated without a code change. Supports manual dry-run via workflow_dispatch. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Adds a pull_request trigger scoped to changes to this workflow file. When triggered by a PR, DRY_RUN is forced to true so the workflow validates detection logic without modifying any branches or PRs. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a scheduled GitHub Actions workflow to automatically close and delete stale “test release” PRs/branches created by the release pipeline, and to remove orphaned staging branches with no associated open PR.
Changes:
- Introduces a daily (and manually-dispatchable) cleanup workflow with a dry-run mode.
- Closes stale PRs whose head branch matches configured test-release prefixes and deletes their branches.
- Deletes stale orphaned branches matching the same prefixes.
- Filter PRs by PR author (msal-js-release-automation), head repository (must match this repo), in addition to head branch prefix — prevents accidental closure of manually opened or fork PRs - Add TEST_PR_AUTHOR repo variable (default: msal-js-release-automation) so the author guard can be updated without a code change - Add set -euo pipefail to both run steps so auth/API failures fail fast instead of silently skipping cleanup - Use committer.date instead of author.date for branch staleness checks to avoid false-positives from cherry-picks with old author dates - URL-encode branch names before interpolating into GitHub API paths to handle branches containing forward slashes Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
|
Reminder: This PR appears to be stale. If this PR is still a work in progress please mark as draft. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a scheduled GitHub Actions workflow that runs daily to close open PRs whose head branch matches a test-release-staging-* prefix and have been open for more than 7 days, then immediately deletes the branch. Also removes orphaned staging branches with no associated open PR.
PRs are matched by head branch name only — never by title — so manually opened PRs are never affected.
Covers both the main and v4-lts release pipelines since both use the same test-release-staging- naming convention.
Branch prefix is driven by the TEST_BRANCH_PREFIXES repository variable (Settings → Actions → Variables) with a hardcoded fallback default, so naming conventions can be updated without a code change.
Supports manual dry-run via workflow_dispatch.