73 lines · yaml
1name: "Labelling new pull requests"2 3permissions:4 contents: read5 6on:7 # It's safe to use pull_request_target here, because we aren't checking out8 # code from the pull request branch.9 # See https://securitylab.github.com/research/github-actions-preventing-pwn-requests/10 pull_request_target:11 types:12 - opened13 - reopened14 - ready_for_review15 - synchronize16 17jobs:18 greeter:19 runs-on: ubuntu-24.0420 permissions:21 pull-requests: write22 # Only comment on PRs that have been opened for the first time, by someone23 # new to LLVM or to GitHub as a whole. Ideally we'd look for FIRST_TIMER24 # or FIRST_TIME_CONTRIBUTOR, but this does not appear to work. Instead check25 # that we do not have any of the other author associations.26 # See https://docs.github.com/en/webhooks/webhook-events-and-payloads?actionType=opened#pull_request27 # for all the possible values.28 if: >-29 (github.event.action == 'opened') &&30 (github.event.pull_request.author_association != 'COLLABORATOR') &&31 (github.event.pull_request.author_association != 'CONTRIBUTOR') &&32 (github.event.pull_request.author_association != 'MANNEQUIN') &&33 (github.event.pull_request.author_association != 'MEMBER') &&34 (github.event.pull_request.author_association != 'OWNER')35 steps:36 - name: Checkout Automation Script37 uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.038 with:39 sparse-checkout: llvm/utils/git/40 ref: main41 42 - name: Setup Automation Script43 working-directory: ./llvm/utils/git/44 run: |45 pip install --require-hashes -r requirements.txt46 47 - name: Greet Author48 working-directory: ./llvm/utils/git/49 run: |50 python3 ./github-automation.py \51 --token '${{ secrets.GITHUB_TOKEN }}' \52 pr-greeter \53 --issue-number "${{ github.event.pull_request.number }}"54 55 automate-prs-labels:56 # Greet first so that only the author gets that notification.57 needs: greeter58 runs-on: ubuntu-24.0459 # Ignore PRs with more than 10 commits. Pull requests with a lot of60 # commits tend to be accidents usually when someone made a mistake while trying61 # to rebase. We want to ignore these pull requests to avoid excessive62 # notifications.63 # always() means that even if greeter is skipped, this job will run.64 if: >65 always() && github.repository == 'llvm/llvm-project' &&66 github.event.pull_request.draft == false &&67 github.event.pull_request.commits < 1068 steps:69 - uses: actions/labeler@634933edcd8ababfe52f92936142cc22ac488b1b # v6.0.170 with:71 configuration-path: .github/new-prs-labeler.yml72 repo-token: ${{ secrets.ISSUE_SUBSCRIBER_TOKEN }}73