Skip to content
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

Merged
merged 8 commits into from
Mar 8, 2025

Conversation

edvilme
Copy link
Member

@edvilme edvilme commented Mar 7, 2025

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

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Infrastructure untriaged Request triage from a team member labels Mar 7, 2025
@edvilme edvilme marked this pull request as ready for review March 8, 2025 00:34
@Copilot Copilot bot review requested due to automatic review settings March 8, 2025 00:34
Copy link
Contributor

@Copilot 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.

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.

@edvilme edvilme requested a review from Copilot March 8, 2025 00:47
Copy link
Contributor

@Copilot 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.

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");

@edvilme edvilme requested a review from a team March 8, 2025 00:49

jobs:
remove-labels:
if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'Branding')
Copy link
Member

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"?

Copy link
Member Author

Choose a reason for hiding this comment

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

The job name?

Comment on lines +23 to +49
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");
Copy link
Member Author

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.

@edvilme edvilme merged commit d537f71 into dotnet:main Mar 8, 2025
39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Infrastructure untriaged Request triage from a team member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants