From a873494de9ba8dc2a42dbe8a51a3d8d1d7ddcc98 Mon Sep 17 00:00:00 2001 From: sekyondaMeta <127536312+sekyondaMeta@users.noreply.github.com> Date: Tue, 8 Oct 2024 13:50:50 -0400 Subject: [PATCH 1/3] Create link_checkPR.yml --- .github/workflows/link_checkPR.yml | 60 ++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 .github/workflows/link_checkPR.yml diff --git a/.github/workflows/link_checkPR.yml b/.github/workflows/link_checkPR.yml new file mode 100644 index 0000000000..3090c0e5c2 --- /dev/null +++ b/.github/workflows/link_checkPR.yml @@ -0,0 +1,60 @@ +name: link check on PR + +on: + pull_request: + branches: [main] + +jobs: + check-links: + runs-on: ubuntu-latest + steps: + - name: Clone repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + ref: ${{github.event.pull_request.head.ref}} + repository: ${{github.event.pull_request.head.repo.full_name}} + + - name: Check out main branch + run: git checkout main + + - name: Dump all links from main + id: dump_links_from_main + uses: lycheeverse/lychee-action@v1 + with: + args: | + --dump + --include-fragments + . + output: ./links-main.txt + + - name: Stash untracked files + run: git stash push --include-untracked + + - name: Check out feature branch + run: git checkout ${{ github.head_ref }} + + - name: Apply stashed changes + # Apply stashed changes, ignore errors if stash is empty + run: git stash pop || true + + - name: Append links-main.txt to .lycheeignore + run: cat links-main.txt >> .lycheeignore + + - name: Check links + uses: lycheeverse/lychee-action@v1 + with: + args: | + --no-progress + --include-fragments + . + # Fail action on broken links + fail: true + + - name: Suggestions + if: failure() + run: | + echo -e "\nPlease review the links reported in the Check links step above." + echo -e "If a link is valid but fails due to a CAPTCHA challenge, IP blocking, login requirements, etc., + consider adding such links to .lycheeignore file to bypass future checks.\n" + exit 1 From 331bf179fd1b3125e9a2152956355d8f7c3b903d Mon Sep 17 00:00:00 2001 From: sekyondaMeta <127536312+sekyondaMeta@users.noreply.github.com> Date: Tue, 8 Oct 2024 13:52:36 -0400 Subject: [PATCH 2/3] Create .lycheeignore --- .lycheeignore | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .lycheeignore diff --git a/.lycheeignore b/.lycheeignore new file mode 100644 index 0000000000..2170cb3166 --- /dev/null +++ b/.lycheeignore @@ -0,0 +1,2 @@ +# Used for links to be ignored during the link check. +# Add link to file along with comment as to why it should be ignored From cee69f6ef340e52352fa9a587152ef0a8403b792 Mon Sep 17 00:00:00 2001 From: sekyondaMeta <127536312+sekyondaMeta@users.noreply.github.com> Date: Tue, 8 Oct 2024 13:54:34 -0400 Subject: [PATCH 3/3] Update link_checkPR.yml --- .github/workflows/link_checkPR.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/link_checkPR.yml b/.github/workflows/link_checkPR.yml index 3090c0e5c2..b30c33b13c 100644 --- a/.github/workflows/link_checkPR.yml +++ b/.github/workflows/link_checkPR.yml @@ -1,3 +1,6 @@ +#Checks links in a PR to ensure they are valid. If link is valid but failing, it can be added to the .lycheeignore file +#Code source: https://github.com/lycheeverse/lychee-action/issues/238 + name: link check on PR on: