diff --git a/.github/workflows/pr-check_redirects.yml b/.github/workflows/pr-check_redirects.yml index f33828254ddce19..93d6a69da5e30a4 100644 --- a/.github/workflows/pr-check_redirects.yml +++ b/.github/workflows/pr-check_redirects.yml @@ -4,10 +4,6 @@ on: pull_request: branches: - main - paths: - - .nvmrc - - files/** - - .github/workflows/pr-check_redirects.yml jobs: check-redirects: @@ -22,11 +18,26 @@ jobs: node-version-file: ".nvmrc" cache: yarn + # This is a "required" workflow so path filtering can not be used: + # https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/collaborating-on-repositories-with-code-quality-features/troubleshooting-required-status-checks#handling-skipped-but-required-checks + # We have to rely on a custom filtering mechanism to run the checks only if required files are modified. + - uses: dorny/paths-filter@v2 + name: See if any file needs checking + id: filter + with: + filters: | + required_files : + - ".nvmrc" + - "files/**" + - ".github/workflows/pr-check_redirects_file.yml" + - name: Install all yarn packages + if: steps.filter.outputs.required_files == 'true' run: yarn --frozen-lockfile env: # https://github.com/microsoft/vscode-ripgrep#github-api-limit-note GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Check redirects file(s) + if: steps.filter.outputs.required_files == 'true' run: yarn content validate-redirects en-us --strict diff --git a/.github/workflows/pr-test.yml b/.github/workflows/pr-test.yml index db3028a686eda1e..7c8b322d8e6b439 100644 --- a/.github/workflows/pr-test.yml +++ b/.github/workflows/pr-test.yml @@ -10,10 +10,6 @@ on: pull_request: branches: - main - paths: - - .nvmrc - - ".github/workflows/pr-test.yml" - - "files/en-us/**" jobs: tests: @@ -31,16 +27,31 @@ jobs: node-version-file: ".nvmrc" cache: yarn + # This is a "required" workflow so path filtering can not be used: + # https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/collaborating-on-repositories-with-code-quality-features/troubleshooting-required-status-checks#handling-skipped-but-required-checks + # We have to rely on a custom filtering mechanism to run the checks only if required files are modified. + - uses: dorny/paths-filter@v2 + name: See if any file needs checking + id: filter + with: + filters: | + required_files : + - ".nvmrc" + - ".github/workflows/pr-test.yml" + - "files/en-us/**" + - name: Install all yarn packages + if: steps.filter.outputs. required_files == 'true' run: yarn --frozen-lockfile env: # https://github.com/microsoft/vscode-ripgrep#github-api-limit-note GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Get changed files + if: steps.filter.outputs.required_files == 'true' run: | # Use the GitHub API to get the list of changed files - # documenation: https://docs.github.com/rest/commits/commits#compare-two-commits + # documentation: https://docs.github.com/rest/commits/commits#compare-two-commits DIFF_DOCUMENTS=$(gh api repos/{owner}/{repo}/compare/${{ env.BASE_SHA }}...${{ env.HEAD_SHA }} \ --jq '.files | .[] | select(.status|IN("added", "modified", "renamed", "copied", "changed")) | .filename')