From f210197ad30f87cbe357ff766a738671081b0472 Mon Sep 17 00:00:00 2001 From: Kevin Duret Date: Mon, 16 Dec 2024 11:16:29 +0100 Subject: [PATCH] enh(ci): workflow to add external label to forked pull requests (#1949) --- .../set-pull-request-external-label.yml | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .github/workflows/set-pull-request-external-label.yml diff --git a/.github/workflows/set-pull-request-external-label.yml b/.github/workflows/set-pull-request-external-label.yml new file mode 100644 index 0000000000..bedeb755b9 --- /dev/null +++ b/.github/workflows/set-pull-request-external-label.yml @@ -0,0 +1,32 @@ +name: set-pull-request-external-label + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +on: + pull_request_target: + +jobs: + set-pull-request-external-label: + if: | + github.event.pull_request.head.repo.fork && + ! contains(github.event.pull_request.labels.*.name, 'external') + runs-on: ubuntu-24.04 + + steps: + - name: Set PR external label + uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 + with: + script: | + const label = 'external'; + try { + await github.rest.issues.addLabels({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + labels: [label] + }); + } catch (e) { + core.warning(`failed to add label ${label}: ${e}`); + }