369afa85eb
Signed-off-by: Justin Williams <Justin.Williams@amd.com>
47 lines
1.4 KiB
YAML
47 lines
1.4 KiB
YAML
name: Auto Label Mainline PRs
|
|
|
|
on:
|
|
pull_request:
|
|
types: [opened, synchronize, reopened, closed]
|
|
|
|
jobs:
|
|
add-label:
|
|
runs-on: ubuntu-latest
|
|
container:
|
|
image: node:16-alpine
|
|
permissions:
|
|
pull-requests: write
|
|
steps:
|
|
- name: Add label to PRs targeting amd-mainline
|
|
uses: actions/github-script@v6
|
|
with:
|
|
script: |
|
|
const pr = context.payload.pull_request;
|
|
const baseBranch = pr.base.ref;
|
|
|
|
// Debug information
|
|
console.log(`Base Branch: ${baseBranch}`);
|
|
|
|
// Check if PR is targeting amd-mainline branch
|
|
const isMainlineTarget = baseBranch === 'amd-mainline';
|
|
|
|
if (isMainlineTarget) {
|
|
// Label to apply
|
|
const labelToAdd = 'Merge amd-mainline';
|
|
|
|
// Try to add the label
|
|
try {
|
|
await github.rest.issues.addLabels({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
issue_number: pr.number,
|
|
labels: [labelToAdd]
|
|
});
|
|
console.log(`Added label "${labelToAdd}" to PR #${pr.number}`);
|
|
} catch (error) {
|
|
console.error(`Error adding label: ${error.message}`);
|
|
}
|
|
} else {
|
|
console.log('PR does not match criteria for automatic labeling');
|
|
}
|