Publish Latest checklists 2026-02-18 #2238
Workflow file for this run
This file contains hidden or 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: | |
| jobs: | |
| link-check: | |
| permissions: | |
| contents: read | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Base | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | |
| with: | |
| repository: OWASP/wstg | |
| ref: ${{ github.base_ref || 'master' }} | |
| path: base | |
| - name: Checkout PR | |
| if: github.event_name == 'pull_request' | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | |
| with: | |
| ref: ${{ github.event.pull_request.head.sha }} | |
| path: pr | |
| fetch-depth: 0 | |
| - name: Save PR number | |
| env: | |
| PR_NUMBER: ${{ github.event.number }} | |
| run: echo $PR_NUMBER > pr_number | |
| - name: Setup Node | |
| uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6 | |
| with: | |
| node-version: 24 | |
| - name: Install dependencies | |
| run: npm install -g markdown-link-check@3.11.0 | |
| - name: Get Changed Files | |
| if: github.event_name == 'pull_request' | |
| id: files | |
| working-directory: pr | |
| run: | | |
| # Get list of changed .md files (excluding .github/) for link checking | |
| git fetch origin ${{ github.base_ref }} | |
| CHANGED_ALL=$(git diff --name-only --diff-filter=d origin/${{ github.base_ref }}...HEAD | grep -v '^\.github/' || true) | |
| FILES=$(echo "$CHANGED_ALL" | grep '\.md$' || true) | |
| # Convert newlines to spaces for compatibility with expected format | |
| FILES_SPACE_SEPARATED=$(echo "$FILES" | tr '\n' ' ' | xargs) | |
| ALL_SPACE_SEPARATED=$(echo "$CHANGED_ALL" | tr '\n' ' ' | xargs) | |
| echo "files_updated=$FILES_SPACE_SEPARATED" >> $GITHUB_OUTPUT | |
| echo "all_changed=$ALL_SPACE_SEPARATED" >> $GITHUB_OUTPUT | |
| echo "## Changed files" >> $GITHUB_STEP_SUMMARY | |
| echo "$FILES" >> $GITHUB_STEP_SUMMARY | |
| shell: bash | |
| - name: PR link check | |
| if: github.event_name == 'pull_request' | |
| env: | |
| FILES: '${{ steps.files.outputs.files_updated }}' | |
| ALL_CHANGED: '${{ steps.files.outputs.all_changed }}' | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| echo "The Following files were changed or created:" | |
| printf '%s\n' $FILES | |
| touch log err | |
| # Copy all changed files (md + images etc.) from pr/ to base/ so link targets exist when we check .md files | |
| for FILE in $ALL_CHANGED; do | |
| [ -z "$FILE" ] && continue | |
| mkdir -p "base/$(dirname "$FILE")" | |
| cp "pr/$FILE" "base/$FILE" | |
| done | |
| # Check only .md files in base/ where relative links can be resolved | |
| for FILE in $FILES; do | |
| if printf '%s\n' "$FILE" | grep -q '.*\.md$'; then | |
| markdown-link-check -q -v -c base/.github/configs/markdown-link-check-config.json "base/$FILE" 1>> log 2>> err | |
| fi | |
| 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: | | |
| cd base | |
| 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"}' | |
| sed -i 's/\[✖\]/\[❌\]/g' 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 | |
| cat artifact.txt >> $GITHUB_STEP_SUMMARY | |
| - name: Upload list of broken links | |
| if: failure() | |
| uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6 | |
| with: | |
| name: artifact | |
| path: | | |
| artifact.txt | |
| pr_number | |
| - name: Upload PR number on success | |
| if: success() | |
| uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6 | |
| with: | |
| name: artifact | |
| path: pr_number |