| name: Issue/PR Subscriber | |
| on: | |
| pull_request_target: | |
| types: | |
| - labeled | |
| issues: | |
| types: | |
| - labeled | |
| permissions: | |
| contents: read | |
| env: | |
| # github.event.number is for pull_request events and | |
| # github.event.issue.number is for issues events. | |
| ISSUE_NUMBER: ${{ github.event.number || github.event.issue.number }} | |
| LABEL_NAME: ${{ github.event.label.name }} | |
| jobs: | |
| subscriber: | |
| environment: | |
| name: main-branch-only | |
| deployment: false | |
| if: github.repository == 'llvm/llvm-project' | |
| runs-on: ubuntu-24.04 | |
| container: | |
| image: "ghcr.io/llvm/amd64/ci-ubuntu-24.04-github-automation:latest@sha256:82b5304c5d99cf5d75a2334885aca57490cbb04f37d07fc49a10a2649824e526" | |
| steps: | |
| - id: app-token | |
| uses: actions/create-github-app-token@1b10c78c7865c340bc4f6099eb2f838309f1e8c3 # v3.1.1 | |
| with: | |
| client-id: ${{ secrets.LLVM_TOKEN_GENERATOR_CLIENT_ID }} | |
| private-key: ${{ secrets.LLVM_TOKEN_GENERATOR_PRIVATE_KEY }} | |
| owner: ${{ github.repository_owner }} | |
| repositories: llvm-project | |
| permission-members: read | |
| permission-contents: read | |
| permission-issues: ${{ case(github.event_name == 'issues', 'write', 'read') }} | |
| permission-pull-requests: ${{ case(github.event_name == 'pull_request_target', 'write', 'read') }} | |
| - name: Update subscribers | |
| env: | |
| EVENT_TRIGGER: ${{ github.event_name }} | |
| ISSUE_SUBSCRIBER_TOKEN: ${{ steps.app-token.outputs.token }} | |
| run: | | |
| case "$EVENT_TRIGGER" in | |
| pull_request_target) | |
| command="pr-subscriber" | |
| ;; | |
| issues) | |
| command="issue-subscriber" | |
| ;; | |
| *) | |
| echo "Unknown event trigger: $EVENT_TRIGGER" | |
| exit 1 | |
| ;; | |
| esac | |
| github-automation.py \ | |
| --token "$ISSUE_SUBSCRIBER_TOKEN" \ | |
| "$command" \ | |
| --issue-number "$ISSUE_NUMBER" \ | |
| --label-name "$LABEL_NAME" |