diff --git a/.github/workflows/label_mainline.yml b/.github/workflows/label_mainline.yml new file mode 100644 index 0000000000..21e4f48ee3 --- /dev/null +++ b/.github/workflows/label_mainline.yml @@ -0,0 +1,46 @@ +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'); + }