name: Check Labels on: # We need pull_request_target to be able to post comments on PRs from forks. # Only allow pull_request_target when merging to main, not some historical branch. # # Make sure to don't introduce explicit checking out and installing/running # untrusted user code into this workflow! pull_request_target: types: [opened, synchronize, reopened, labeled, unlabeled] branches: [main] # To check labels on ghstack PRs. # Note: as pull_request doesn't trigger on PRs targeting main, # to test changes to the workflow itself one needs to create # a PR that targets a gh/**/base branch. pull_request: types: [opened, synchronize, reopened, labeled, unlabeled] branches: [gh/**/base] workflow_dispatch: inputs: pr_number: description: 'PR number to check labels for' required: true concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}-${{ github.event_name == 'workflow_dispatch' }} cancel-in-progress: true jobs: check-labels: permissions: contents: read pull-requests: write name: Check labels if: github.repository_owner == 'pytorch' runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v3 with: fetch-depth: 0 - uses: actions/setup-python@v4 with: python-version: '3.10' # Not the direct dependencies but the script uses trymerge - run: pip install pyyaml==6.0 rockset==1.0.3 - name: Check labels env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} PR_NUM: ${{ github.event.number || github.event.inputs.pr_number }} run: | set -ex python3 .github/scripts/check_labels.py --exit-non-zero "${PR_NUM}"