-
-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add broken link checker GitHub workflow
- Loading branch information
Showing
4 changed files
with
81 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Credit to https://github.com/OWASP/CheatSheetSeries | ||
name: Markdown Broken Link Check | ||
|
||
on: | ||
push: | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
link-check: | ||
runs-on: ubuntu-22.04 | ||
env: | ||
CI: true | ||
steps: | ||
- name: Setup Action | ||
uses: actions/checkout@v3 | ||
- name: Setup Node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 12.x | ||
- name: Install dependencies | ||
run: npm install | ||
- name: Run link check | ||
run: npm run link-check | ||
- name: Show broken links | ||
if: failure() | ||
run: | | ||
cat log | awk -v RS="FILE:" 'match($0, /(\S*\.md).*\[✖\].*(\d*\slinks\schecked\.)(.*)/, arr ) { print "FILE:"arr[1] arr[3] > "brokenlinks"}' | ||
rm -f err log | ||
cat brokenlinks | ||
links=`cat brokenlinks` | ||
links="${links//'%'/'%25'}" | ||
links="${links//$'\n'/'%0A'}" | ||
links="${links//$'\r'/'%0D'}" | ||
echo ::set-output name=links::**Following links are broken:** %0A$links | ||
- name: Send comment to PR with broken links | ||
if: failure() && github.event_name == 'pull_request' | ||
uses: thollander/actions-comment-pull-request@main | ||
with: | ||
message: ${{ steps.brokenlinks.outputs.links }} | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,5 @@ | |
_site/ | ||
node_modules/ | ||
package-lock.json | ||
/log | ||
/err |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"ignorePatterns": [ | ||
{ | ||
"pattern": "^bundle.zip" | ||
}, | ||
{ | ||
"pattern": "^News.xml" | ||
}, | ||
{ | ||
"pattern": "^/" | ||
}, | ||
{ | ||
"pattern": "vincent.bernat.im" | ||
}, | ||
{ | ||
"pattern": "developer.android.com" | ||
}, | ||
{ | ||
"pattern": "csrc.nist.gov" | ||
}, | ||
{ | ||
"pattern": "www.exploit-db.com" | ||
} | ||
], | ||
"httpHeaders": [ | ||
{ | ||
"urls": ["https://", "http://"], | ||
"headers": { | ||
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:64.0) Gecko/20100101 Firefox/64.0" | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters