From cc7accf0e7ace4bd8d93b36aeefb7736c5933e6d Mon Sep 17 00:00:00 2001 From: Mariell Hoversholm Date: Tue, 13 May 2025 15:00:01 +0200 Subject: [PATCH] Actions: Add a workflow to add pr/external labels (#105326) --- .github/CODEOWNERS | 1 + .github/commands.json | 8 ++++++ .github/pr-commands.json | 32 --------------------- .github/workflows/pr-external-labelling.yml | 25 ++++++++++++++++ 4 files changed, 34 insertions(+), 32 deletions(-) create mode 100644 .github/workflows/pr-external-labelling.yml diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index f4484f2ee89..162ba2a6239 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -790,6 +790,7 @@ embed.go @grafana/grafana-as-code /.github/workflows/pr-codeql-analysis-javascript.yml @DanCech /.github/workflows/pr-codeql-analysis-python.yml @DanCech /.github/workflows/pr-commands.yml @tolzhabayev +/.github/workflows/pr-external-labelling.yml @Proximyst /.github/workflows/pr-patch-check-event.yml @grafana/grafana-developer-enablement-squad /.github/workflows/pr-test-integration.yml @grafana/grafana-backend-group /.github/workflows/reject-gh-secrets.yml @grafana/grafana-operator-experience-squad diff --git a/.github/commands.json b/.github/commands.json index f92e29a215b..7afad2e08c9 100644 --- a/.github/commands.json +++ b/.github/commands.json @@ -1194,5 +1194,13 @@ "addToProject": { "url": "https://github.com/orgs/grafana/projects/699" } + }, + { + "type": "label", + "name": "type/docs", + "action": "addToProject", + "addToProject": { + "url": "https://github.com/orgs/grafana/projects/69" + } } ] diff --git a/.github/pr-commands.json b/.github/pr-commands.json index c8117bd6577..f9934555782 100644 --- a/.github/pr-commands.json +++ b/.github/pr-commands.json @@ -253,38 +253,6 @@ "action": "updateLabel", "addLabel": "area/alerting" }, - { - "type": "label", - "name": "area/alerting", - "action": "addToProject", - "addToProject": { - "url": "https://github.com/orgs/grafana/projects/52" - } - }, - { - "type": "author", - "name": "pr/external", - "notMemberOf": { - "org": "grafana" - }, - "ignoreList": [ - "renovate[bot]", - "dependabot[bot]", - "grafana-delivery-bot[bot]", - "grafanabot", - "alerting-team[bot]" - ], - "action": "updateLabel", - "addLabel": "pr/external" - }, - { - "type": "label", - "name": "type/docs", - "action": "addToProject", - "addToProject": { - "url": "https://github.com/orgs/grafana/projects/69" - } - }, { "type": "changedfiles", "matches": [ diff --git a/.github/workflows/pr-external-labelling.yml b/.github/workflows/pr-external-labelling.yml new file mode 100644 index 00000000000..62bd9655edd --- /dev/null +++ b/.github/workflows/pr-external-labelling.yml @@ -0,0 +1,25 @@ +name: External PR labelling + +on: + # We need "write" permissions on the PR to be able to add a label. + pull_request_target: # zizmor: ignore[dangerous-triggers] We need this to have labelling permissions. There are no user inputs here, so we should be fine. + types: + - opened + +permissions: {} + +jobs: + label-if-external: + name: Add 'pr/external' label if the PR is external + if: github.event.pull_request.author_association != 'MEMBER' && github.event.pull_request.author_association != 'OWNER' + runs-on: ubuntu-latest + permissions: + pull-requests: write # to write the label + + steps: + - name: Add the 'pr/external' label + env: + PR_NUMBER: ${{ github.event.pull_request.number }} + run: | + echo "Adding 'pr/external' label to the PR" + gh pr edit "$PR_NUMBER" --add-label pr/external