Skip to content

chore: add workflow to clean up stale test release branches and PRs#8501

Open
hectormmg wants to merge 9 commits into
devfrom
chore/cleanup-test-release-branches
Open

chore: add workflow to clean up stale test release branches and PRs#8501
hectormmg wants to merge 9 commits into
devfrom
chore/cleanup-test-release-branches

Conversation

@hectormmg
Copy link
Copy Markdown
Member

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.

hectormmg and others added 5 commits April 1, 2026 12:13
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>
@hectormmg hectormmg marked this pull request as ready for review April 2, 2026 23:25
@hectormmg hectormmg requested a review from a team as a code owner April 2, 2026 23:25
@hectormmg hectormmg requested review from Copilot April 2, 2026 23:25
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.

Comment thread .github/workflows/cleanup-test-release-branches.yml Outdated
Comment thread .github/workflows/cleanup-test-release-branches.yml
Comment thread .github/workflows/cleanup-test-release-branches.yml
Comment thread .github/workflows/cleanup-test-release-branches.yml Outdated
Comment thread .github/workflows/cleanup-test-release-branches.yml Outdated
hectormmg and others added 3 commits April 3, 2026 13:04
- 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>
@microsoft-github-policy-service
Copy link
Copy Markdown
Contributor

Reminder: This PR appears to be stale. If this PR is still a work in progress please mark as draft.

@microsoft-github-policy-service microsoft-github-policy-service Bot added the Needs: Attention 👋 Awaiting response from the MSAL.js team label Apr 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs: Attention 👋 Awaiting response from the MSAL.js team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants