Add Recon Section for API Chapter #1828
Workflow file for this run
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
name: Markdown Link Check | |
on: | |
pull_request: | |
paths: | |
- '**.md' | |
- '!.github/**' | |
workflow_dispatch: | |
permissions: | |
contents: read | |
jobs: | |
link-check: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Setup Action | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{github.event.pull_request.head.ref}} | |
repository: ${{github.event.pull_request.head.repo.full_name}} | |
- name: Save PR number | |
env: | |
PR_NUMBER: ${{ github.event.number }} | |
run: echo $PR_NUMBER > pr_number | |
- name: Setup Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20' | |
- name: Install dependencies | |
run: npm install -g markdown-link-check@3.11.0 | |
- name: Changed Files Exporter | |
if: github.event_name == 'pull_request' | |
id: files | |
uses: umani/changed-files@v4.2.0 | |
with: | |
repo-token: ${{ secrets.GITHUB_TOKEN }} | |
- name: PR link check | |
if: github.event_name == 'pull_request' | |
env: | |
FILES: '${{ steps.files.outputs.files_updated }} ${{ steps.files.outputs.files_created }}' | |
run: | | |
echo "The Following files were changed or created:" | |
echo $FILES | |
touch log err | |
for FILE in $FILES; do echo $FILE | grep -q .*\.md\$ && markdown-link-check -q -v -c .github/configs/markdown-link-check-config.json $FILE 1>> log 2>> err; done | |
if grep -q "ERROR:" err ; then exit 1 ; else echo -e "No broken links found."; fi | |
echo $(cat log) | |
echo $(cat err) | |
- name: Repository link check | |
if: github.event_name == 'workflow_dispatch' | |
run: | | |
touch log err | |
find . -name \*.md -exec markdown-link-check -q -v --config .github/configs/markdown-link-check-config.json {} 1>> log 2>> err \; | |
if grep -q "ERROR:" err ; then exit 1 ; else echo -e "No broken links found."; fi | |
echo $(cat log) | |
echo $(cat err) | |
- name: Show broken links | |
if: failure() | |
run: | | |
cat log | awk -v RS="FILE:" 'match($0, /(\S*\.md).*\[✖\].*([0-9]*\slinks\schecked\.)(.*)/, arr ) { print "FILE:"arr[1] arr[3] > "brokenlinks.txt"}' | |
cat brokenlinks.txt | |
- name: Create artifact for comment | |
if: failure() | |
run: | | |
echo "**The following links are broken:**" > artifact.txt | |
# Copy to generic name for commenting | |
cat brokenlinks.txt | tee -a artifact.txt | |
rm -f err log | |
- name: Upload list of broken links | |
if: failure() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: artifact | |
path: | | |
artifact.txt | |
pr_number |