• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1name: Check Labels
2
3on:
4  # We need pull_request_target to be able to post comments on PRs from forks.
5  # Only allow pull_request_target when merging to main, not some historical branch.
6  #
7  # Make sure to don't introduce explicit checking out and installing/running
8  # untrusted user code into this workflow!
9  pull_request_target:
10    types: [opened, synchronize, reopened, labeled, unlabeled]
11    branches: [main]
12
13  # To check labels on ghstack PRs.
14  # Note: as pull_request doesn't trigger on PRs targeting main,
15  # to test changes to the workflow itself one needs to create
16  # a PR that targets a gh/**/base branch.
17  pull_request:
18    types: [opened, synchronize, reopened, labeled, unlabeled]
19    branches: [gh/**/base]
20
21  workflow_dispatch:
22    inputs:
23      pr_number:
24        description: 'PR number to check labels for'
25        required: true
26
27concurrency:
28  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}-${{ github.event_name == 'workflow_dispatch' }}
29  cancel-in-progress: true
30
31jobs:
32  check-labels:
33    permissions:
34      contents: read
35      pull-requests: write
36    name: Check labels
37    if: github.repository_owner == 'pytorch'
38    runs-on: ubuntu-22.04
39    steps:
40      - uses: actions/checkout@v3
41        with:
42          fetch-depth: 0
43      - uses: actions/setup-python@v4
44        with:
45          python-version: '3.10'
46      # Not the direct dependencies but the script uses trymerge
47      - run: pip install pyyaml==6.0 rockset==1.0.3
48      - name: Check labels
49        env:
50          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51          PR_NUM: ${{ github.event.number || github.event.inputs.pr_number }}
52        run: |
53          set -ex
54          python3 .github/scripts/check_labels.py --exit-non-zero "${PR_NUM}"
55