diff options
author | Gina Häußge <gina@octoprint.org> | 2021-09-14 19:55:46 +0300 |
---|---|---|
committer | Gina Häußge <gina@octoprint.org> | 2021-09-14 19:55:46 +0300 |
commit | 5f7679b11baafc0bb58861c462b9e4568041080b (patch) | |
tree | 6230e5c3c6e1f3acb07e60cbdd02a6a9518f07f2 /.github | |
parent | 0e1ada7a0e8445a86da329ebd222fa03020c6e90 (diff) |
👷 Add target branch labels to PRs
Diffstat (limited to '.github')
-rw-r--r-- | .github/workflows/pr_automation.yml | 23 |
1 files changed, 23 insertions, 0 deletions
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 }} |