diff --git a/.github/workflows/cla.yaml b/.github/workflows/cla.yaml index 71c2e90..110039d 100644 --- a/.github/workflows/cla.yaml +++ b/.github/workflows/cla.yaml @@ -2,20 +2,41 @@ name: "CLA Assistant" on: issue_comment: types: [created] + # zizmor: ignore[dangerous-triggers] The CLA bot needs pull_request_target and never checks out PR code. pull_request_target: types: [opened,closed,synchronize] +permissions: + contents: read + jobs: CLAssistant: runs-on: ubuntu-latest + # Holds the coder-cla App key; only main may use it. pull_request_target and + # issue_comment runs use the base branch, so only PRs into main are checked. + environment: cla + if: >- + (github.event_name == 'issue_comment' && (github.event.comment.body == 'recheck' || github.event.comment.body == 'I have read the CLA Document and I hereby sign the CLA')) || + (github.event_name == 'pull_request_target' && github.event.pull_request.base.ref == 'main') + permissions: + pull-requests: write steps: + # Writes signatures to coder/cla, which GITHUB_TOKEN can't reach. + - name: Generate coder-cla App token + id: cla_token + uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.0 + with: + app-id: ${{ secrets.CODER_CLA_APP_ID }} + private-key: ${{ secrets.CODER_CLA_APP_PRIVATE_KEY }} + owner: coder + repositories: cla + permission-contents: write + - name: "CLA Assistant" - if: (github.event.comment.body == 'recheck' || github.event.comment.body == 'I have read the CLA Document and I hereby sign the CLA') || github.event_name == 'pull_request_target' - uses: contributor-assistant/github-action@v2.6.1 + uses: contributor-assistant/github-action@ca4a40a7d1004f18d9960b404b97e5f30a505a08 # v2.6.1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # the below token should have repo scope and must be manually added by you in the repository's secret - PERSONAL_ACCESS_TOKEN : ${{ secrets.CDRCOMMUNITY_GITHUB_TOKEN }} + PERSONAL_ACCESS_TOKEN: ${{ steps.cla_token.outputs.token }} with: remote-organization-name: 'coder' remote-repository-name: 'cla'