Skip to content

dotnet CLI: Rename project and command sub-folders #272

dotnet CLI: Rename project and command sub-folders

dotnet CLI: Rename project and command sub-folders #272

name: Remove Lockdown Label from PRs
on:
pull_request:
types: [closed]
permissions:
actions: write
pull-requests: write
jobs:
remove-labels:
if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'Branding')
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: PR's only change is <VersionFeature> in eng/Versions.props
id: only_version_feature_changed
uses: actions/github-script@v4
with:
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");
- name: Remove Branch Lockdown label from other PRs targeting this branch
if: steps.only_version_feature_changed.outputs.only_version_feature_changed == 'true'
uses: actions/github-script@v4
with:
script: |
const prs = await github.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
base: github.event.pull_request.base.ref,
per_page: 300
});
const filtered_prs = prs.data
.filter(pr => pr.number !== github.context.payload.pull_request.number)
.filter(pr => pr.labels.map(label => label.name).includes('Branch Lockdown'));
for (const pr of filtered_prs) {
await github.issues.removeLabel({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pr.number,
name: 'Branch Lockdown'
});
console.log(`Removed Branch Lockdown label from PR #${pr.number}`);
}