From 93cd0b84b58fd7a1c8b21f9db545db82694ba1b3 Mon Sep 17 00:00:00 2001 From: rahulpinto19 Date: Mon, 16 Feb 2026 06:11:21 +0000 Subject: [PATCH] test-pr-comment --- .github/workflows/link_checker_workflow.yaml | 36 ++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/.github/workflows/link_checker_workflow.yaml b/.github/workflows/link_checker_workflow.yaml index 591221d16e0..f5a1e98e686 100644 --- a/.github/workflows/link_checker_workflow.yaml +++ b/.github/workflows/link_checker_workflow.yaml @@ -23,8 +23,33 @@ jobs: steps: - name: Checkout Repository uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 + with: + fetch-depth: 0 + - name: Identify Changed Files + id: changed-files + shell: bash + run: | + git fetch origin main + CHANGED_FILES=$(git diff --name-only --diff-filter=ACMRT origin/main...HEAD) + + if [ -z "$CHANGED_FILES" ]; then + echo "No markdown files changed. Skipping checks." + echo "HAS_CHANGES=false" >> $GITHUB_ENV + else + echo "--- Changed Files to Scan ---" + echo "$CHANGED_FILES" + echo "-----------------------------" + + # Flatten newlines to spaces for the args list + FILES_FLAT=$(echo "$CHANGED_FILES" | tr '\n' ' ') + + echo "CHECK_FILES=$FILES_FLAT" >> $GITHUB_ENV + echo "HAS_CHANGES=true" >> $GITHUB_ENV + fi + - name: Restore lychee cache + if: env.HAS_CHANGES == 'true' uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5 with: path: .lycheecache @@ -33,6 +58,7 @@ jobs: - name: Link Checker id: lychee-check + if: env.HAS_CHANGES == 'true' uses: lycheeverse/lychee-action@a8c4c7cb88f0c7386610c35eb25108e448569cb0 # v2 continue-on-error: true with: @@ -42,8 +68,7 @@ jobs: --cache --max-cache-age 1d --exclude '^neo4j\+.*' --exclude '^bolt://.*' - README.md - docs/ + ${{ env.CHECK_FILES }} output: lychee-report.md format: markdown fail: true @@ -51,6 +76,13 @@ jobs: debug: false env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Create PR Comment + if: env.HAS_CHANGES == 'true' && steps.lychee-check.outputs.status != '0' + uses: peter-evans/create-or-update-comment@v4 + with: + issue-number: ${{ github.event.pull_request.number }} + body-path: lychee-report.md + edit-mode: replace - name: Display Failure Report # Run this ONLY if the link checker failed