-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
[Github Actions] Remove Branch Lockdown Labels on Branding Merge #47371
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Overview
This PR automates the removal of "Branch Lockdown" labels when a branding pull request is successfully merged. The workflow checks that only the in eng/Versions.props is modified and then removes lockdown labels from other open PRs targeting the same branch.
Reviewed Changes
File | Description |
---|---|
.github/workflows/remove-lockdown-label.yml | Adds a GitHub Actions workflow that validates PR file changes and removes "Branch Lockdown" labels from related PRs |
Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Overview
This PR introduces a new GitHub Actions workflow to automate the removal of "Branch Lockdown" labels from PRs targeting the same branch once a branding PR is merged.
- Adds a workflow that triggers on closed PR events and checks that only the in eng/Versions.props has been modified.
- Implements logic to identify candidate PRs and remove the "Branch Lockdown" label from them.
Reviewed Changes
File | Description |
---|---|
.github/workflows/remove-lockdown-label.yml | New workflow that evaluates PR file changes and removes labels accordingly |
Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
.github/workflows/remove-lockdown-label.yml:35
- Consider using core.setOutput instead of core.exportVariable to set the output 'only_version_feature_changed' so that the subsequent step can correctly read the value.
core.exportVariable("only_version_feature_changed", "false");
|
||
jobs: | ||
remove-labels: | ||
if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'Branding') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you make it "Update branding to"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The job name?
script: | | ||
const otherChangesMessage = "❌ Changes in eng/Versions.props other than <VersionFeature> found"; | ||
const onlyVersionFeatureMessage = "✅ PR's only change is <VersionFeature> in eng/Versions.props"; | ||
const prNumber = context.payload.pull_request.number; | ||
const { data: files } = await github.pulls.listFiles({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
pull_number: prNumber | ||
}); | ||
// If files other than eng/Versions.props are changed, output message and exit | ||
if (files.some(file => file.filename !== "eng/Versions.props")) { | ||
console.log(otherChangesMessage); | ||
core.exportVariable("only_version_feature_changed", "false"); | ||
return; | ||
} | ||
// Iterate through the patch of eng/Versions.props to check for changes other than <VersionFeature> | ||
const versionsPropsFile = files.find(file => file.filename === "eng/Versions.props"); | ||
const patchLines = versionsPropsFile.patch.split("\n").filter(l => l.startsWith("+") || l.startsWith("-")); | ||
for (const line of patchLines) { | ||
if (!line.includes("<VersionFeature>")) { | ||
console.log(otherChangesMessage); | ||
core.exportVariable("only_version_feature_changed", "false"); | ||
return; | ||
} | ||
} | ||
console.log(onlyVersionFeatureMessage); | ||
core.exportVariable("only_version_feature_changed", "true"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This part is optional, but I think it ensures we don't accidentaly merge a PR that has the branding label, branch lockdown labels are removed, prs are allowed to merge, and a whole mess happens.
It would be really useful if
Branch Lockdown
labels were automatically removed once branding prs check in, as that would automate some blocking points for codeflow.The job only runs on PR's labeled
Branding
When the PR gets merged, it will check the file differences to make sure it is a proper branding PR
If it is, it will remove the
Branch Lockdown
labels from other PRs targeting the same branch