From 450d5bb9aef92c25a1722f9b9a053b594c8b5b5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Wed, 27 Oct 2021 12:57:01 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=B7=E2=80=8D=E2=99=82=EF=B8=8F=20Fix?= =?UTF-8?q?=20PR=20automation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Labels weren't refreshed properly in a step, causing labeling to be reverted and thereby causing issues in a later step. --- .github/workflows/pr_automation.yml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pr_automation.yml b/.github/workflows/pr_automation.yml index c1f115ecf..2d3ae592b 100644 --- a/.github/workflows/pr_automation.yml +++ b/.github/workflows/pr_automation.yml @@ -12,13 +12,18 @@ jobs: with: repo-token: "${{ secrets.GITHUB_TOKEN }}" - - uses: actions/github-script@v2 + - uses: actions/github-script@v5 with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | - let labels = []; + # fetch a fresh set of labels, they might have changed earlier + const issueLabels = await github.rest.issues.listLabelsOnIssue({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number + }); + let labels = issueLabels.data.map(label => label.name); 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)) { @@ -27,7 +32,7 @@ jobs: } if (setLabels) { - github.issues.setLabels({ + github.rest.issues.setLabels({ issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo,