llvm-project
75 строк · 2.8 Кб
1name: "Labelling new pull requests"2
3permissions:4contents: 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/10pull_request_target:11types:12- opened13- reopened14- ready_for_review15- synchronize16
17jobs:18greeter:19runs-on: ubuntu-latest20permissions:21pull-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.28if: >-29(github.repository == 'llvm/llvm-project') &&30(github.event.action == 'opened') &&31(github.event.pull_request.author_association != 'COLLABORATOR') &&32(github.event.pull_request.author_association != 'CONTRIBUTOR') &&33(github.event.pull_request.author_association != 'MANNEQUIN') &&34(github.event.pull_request.author_association != 'MEMBER') &&35(github.event.pull_request.author_association != 'OWNER')36steps:37- name: Checkout Automation Script38uses: actions/checkout@v439with:40sparse-checkout: llvm/utils/git/41ref: main42
43- name: Setup Automation Script44working-directory: ./llvm/utils/git/45run: |46pip install --require-hashes -r requirements.txt
47
48- name: Greet Author49working-directory: ./llvm/utils/git/50run: |51python3 ./github-automation.py \
52--token '${{ secrets.GITHUB_TOKEN }}' \
53pr-greeter \
54--issue-number "${{ github.event.pull_request.number }}"
55
56automate-prs-labels:57# Greet first so that only the author gets that notification.58needs: greeter59runs-on: ubuntu-latest60# Ignore PRs with more than 10 commits. Pull requests with a lot of61# commits tend to be accidents usually when someone made a mistake while trying62# to rebase. We want to ignore these pull requests to avoid excessive63# notifications.64# always() means that even if greeter is skipped, this job will run.65if: >66always() && github.repository == 'llvm/llvm-project' &&
67github.event.pull_request.draft == false &&
68github.event.pull_request.commits < 10
69steps:70- uses: actions/labeler@v471with:72configuration-path: .github/new-prs-labeler.yml73# workaround for https://github.com/actions/labeler/issues/11274sync-labels: ''75repo-token: ${{ secrets.ISSUE_SUBSCRIBER_TOKEN }}76