diff --git a/.github/workflows/pr_automation.yml b/.github/workflows/pr_automation.yml index d0e04b09b..c1f115ecf 100644 --- a/.github/workflows/pr_automation.yml +++ b/.github/workflows/pr_automation.yml @@ -12,6 +12,29 @@ jobs: with: repo-token: "${{ secrets.GITHUB_TOKEN }}" + - uses: actions/github-script@v2 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + let labels = []; + let setLabels = false; + context.payload.pull_request.labels.forEach(label => { labels.push(label.name) }); + + let target = context.payload.pull_request.base.ref; + if (["maintenance", "devel", "staging/maintenance", "staging/devel", "master"].includes(target)) { + labels.push(`targets ${target}`); + setLabels = true; + } + + if (setLabels) { + github.issues.setLabels({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + labels: labels + }) + } + - uses: OctoPrint/actions/pr-validation@main with: repo-token: ${{ secrets.GITHUB_TOKEN }}