diff --git a/.github/workflows/_link_check.yml b/.github/workflows/_link_check.yml index dfdbd04469f..6a9e8272711 100644 --- a/.github/workflows/_link_check.yml +++ b/.github/workflows/_link_check.yml @@ -7,6 +7,7 @@ on: jobs: lint-urls: + if: ${{ github.event_name != 'pull_request' || !contains(github.event.pull_request.labels.*.name, 'skip-url-lint') }} uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main with: runner: linux.2xlarge @@ -17,13 +18,15 @@ jobs: timeout: 90 script: | ./scripts/lint_urls.sh $( - [ "${{ github.event_name }}" = "pull_request" ] \ - && git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} \ - || [ "${{ github.event_name }}" = "push" ] \ - && git diff --name-only ${{ github.event.before }} ${{ github.sha }} + { [ "${{ github.event_name }}" = "pull_request" ] \ + && git diff --name-only "${{ github.event.pull_request.base.sha }}...${{ github.event.pull_request.head.sha }}"; } \ + || \ + { [ "${{ github.event_name }}" = "push" ] \ + && git diff --name-only "${{ github.event.before }}...${{ github.sha }}"; } ) lint-xrefs: + if: ${{ github.event_name != 'pull_request' || !contains(github.event.pull_request.labels.*.name, 'skip-xref-lint') }} uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main with: runner: linux.2xlarge @@ -34,8 +37,9 @@ jobs: timeout: 90 script: | ./scripts/lint_xrefs.sh $( - [ "${{ github.event_name }}" = "pull_request" ] \ - && git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} \ - || [ "${{ github.event_name }}" = "push" ] \ - && git diff --name-only ${{ github.event.before }} ${{ github.sha }} + { [ "${{ github.event_name }}" = "pull_request" ] \ + && git diff --name-only "${{ github.event.pull_request.base.sha }}...${{ github.event.pull_request.head.sha }}"; } \ + || \ + { [ "${{ github.event_name }}" = "push" ] \ + && git diff --name-only "${{ github.event.before }}...${{ github.sha }}"; } )