diff --git a/.github/workflows/links-fail-fast.yml b/.github/workflows/links-fail-fast.yml index 4896b60be..4d7357899 100644 --- a/.github/workflows/links-fail-fast.yml +++ b/.github/workflows/links-fail-fast.yml @@ -10,8 +10,32 @@ on: permissions: read-all jobs: + changedfiles: + name: changed files + runs-on: ubuntu-latest + env: + PR_HEAD: ${{ github.event.pull_request.head.sha }} + outputs: + files: ${{ steps.changes.outputs.files }} + steps: + - name: Checkout Repo + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + fetch-depth: 0 + - name: Get changed files + id: changes + run: | + files=$(git diff --name-only --diff-filter=ACMRTUXB $(git merge-base origin/main $PR_HEAD) $PR_HEAD | xargs) + + # Used for debugging. + echo "files=$files" + + echo "files=$files" >> $GITHUB_OUTPUT + check-links: runs-on: ubuntu-latest + needs: changedfiles + if: ${{needs.changedfiles.outputs.files}} permissions: contents: read steps: @@ -31,7 +55,8 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: fail: true - args: --max-concurrency 5 --cache --max-cache-age 1d --cache-exclude-status 300..=599 . + failIfEmpty: false + args: --max-concurrency 5 --cache --max-cache-age 1d --cache-exclude-status 300..=599 ${{needs.changedfiles.outputs.files}} - name: Save lychee cache if: always()