From 2086044c79130a87a3b78b44b50562dd3515ca7b Mon Sep 17 00:00:00 2001 From: Trent Mick Date: Tue, 19 Mar 2024 09:08:46 -0700 Subject: [PATCH] ci: refactor labeler workflow (#89) This aligns with how membership-checking and labeling is done in the same workflow in other repos of ours. --- .github/workflows/labeler.yml | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml index 9ad2008d..107a2d5f 100644 --- a/.github/workflows/labeler.yml +++ b/.github/workflows/labeler.yml @@ -5,31 +5,30 @@ on: pull_request_target: types: [opened] -# 'issues: write' for https://docs.github.com/en/rest/issues/labels?apiVersion=2022-11-28#add-labels-to-an-issue +# '*: write' permissions for https://docs.github.com/en/rest/issues/labels?apiVersion=2022-11-28#add-labels-to-an-issue permissions: contents: read issues: write + pull_requests: write jobs: triage: runs-on: ubuntu-latest steps: - - name: Check team membership for user - uses: elastic/get-user-teams-membership@1.1.0 - id: checkUserMember + - id: is_elastic_member + uses: elastic/apm-pipeline-library/.github/actions/is-member-elastic-org@current with: username: ${{ github.actor }} - team: 'apm' - usernamesToExclude: | - apmmachine - dependabot - dependabot[bot] - GITHUB_TOKEN: ${{ secrets.APM_TECH_USER_TOKEN }} + token: ${{ secrets.APM_TECH_USER_TOKEN }} - name: Add community and triage labels - if: steps.checkUserMember.outputs.isTeamMember != 'true' && steps.checkUserMember.outputs.isExcluded != 'true' - uses: actions-ecosystem/action-add-labels@v1 + if: contains(steps.is_elastic_member.outputs.result, 'false') && github.actor != 'dependabot[bot]' + uses: actions/github-script@v7 with: - labels: | - community - triage + script: | + github.rest.issues.addLabels({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + labels: ["community", "triage"] + })