diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml index 6adcac6f9..daa9bf52b 100644 --- a/.github/workflows/labeler.yml +++ b/.github/workflows/labeler.yml @@ -1,38 +1,42 @@ name: "Issue Labeler" + +# pull_request_target is kept so that PRs from forks can be labeled (the pull_request token +# is read-only for forks and has no access to secrets). No PR code is checked out or run: +# only event metadata is read. on: issues: types: [opened] pull_request_target: types: [opened] -# '*: 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 +permissions: {} jobs: triage: runs-on: ubuntu-latest + permissions: + issues: write + pull-requests: write env: NUMBER: ${{ github.event.issue.number || github.event.pull_request.number }} GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + REPO: ${{ github.repository }} steps: - name: Get token id: get_token - uses: actions/create-github-app-token@v3 + uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.0 with: app-id: ${{ secrets.OBS_AUTOMATION_APP_ID }} private-key: ${{ secrets.OBS_AUTOMATION_APP_PEM }} permission-members: read - name: Add agent-python label - run: gh issue edit "$NUMBER" --add-label "agent-python" --repo "${{ github.repository }}" + run: gh issue edit "$NUMBER" --add-label "agent-python" --repo "$REPO" - id: is_elastic_member - uses: elastic/oblt-actions/github/is-member-of@v1 + uses: elastic/oblt-actions/github/is-member-of@208d03b3c3dfec874e5f2d73b2c938e493fc6953 # v1.43.0 with: github-org: "elastic" github-user: ${{ github.actor }} github-token: ${{ steps.get_token.outputs.token }} - name: Add community and triage labels if: contains(steps.is_elastic_member.outputs.result, 'false') && github.actor != 'dependabot[bot]' && github.actor != 'elastic-observability-automation[bot]' - run: gh issue edit "$NUMBER" --add-label "community,triage" --repo "${{ github.repository }}" + run: gh issue edit "$NUMBER" --add-label "community,triage" --repo "$REPO"