Shortcut 6757: acquisition filter #287
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
name: Label PRs with skip-sc | |
on: | |
pull_request: | |
types: [opened, reopened, synchronize] | |
jobs: | |
apply-skip-sc-label: | |
runs-on: ubuntu-latest | |
permissions: | |
pull-requests: write | |
steps: | |
- name: Add skip-sc label if author is in the list and branch starts with sc- | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
const pr = context.payload.pull_request; | |
const prAuthor = pr.user.login; | |
const branchName = pr.head.ref; | |
const relevantUsers = ['swalker2m']; | |
const skipScLabel = 'skip-sc'; | |
if (!branchName.startsWith('sc-')) { | |
console.log(`Branch '${branchName}' does not start with 'sc-'; skipping.`); | |
return; | |
} | |
if (!relevantUsers.includes(prAuthor)) { | |
console.log(`PR author '${prAuthor}' not in the list; skipping.`); | |
return; | |
} | |
const labels = pr.labels.map(l => l.name); | |
if (!labels.includes(skipScLabel)) { | |
await github.rest.issues.addLabels({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: pr.number, | |
labels: [skipScLabel], | |
}); | |
console.log(`Added label "${skipScLabel}" to PR #${pr.number}`); | |
} else { | |
console.log(`Label "${skipScLabel}" already present on PR #${pr.number}`); | |
} |