microsoft/hve-core
Publicmirrored fromhttps://github.com/microsoft/hve-coreAvailable
.github/workflows/markdown-link-check.yml
66lines · modecode
| 1 | name: Markdown Link Check |
| 2 | |
| 3 | on: |
| 4 | workflow_call: |
| 5 | inputs: |
| 6 | soft-fail: |
| 7 | description: 'Whether to continue on broken links' |
| 8 | required: false |
| 9 | type: boolean |
| 10 | default: false |
| 11 | |
| 12 | permissions: |
| 13 | contents: read |
| 14 | |
| 15 | jobs: |
| 16 | markdown-link-check: |
| 17 | name: Check Markdown Links |
| 18 | runs-on: ubuntu-latest |
| 19 | permissions: |
| 20 | contents: read |
| 21 | steps: |
| 22 | - name: Harden Runner |
| 23 | uses: step-security/harden-runner@95d9a5deda9de15063e7595e9719c11c38c90ae2 # v2.10.2 |
| 24 | with: |
| 25 | egress-policy: audit |
| 26 | |
| 27 | - name: Checkout code |
| 28 | uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v4.2.2 |
| 29 | with: |
| 30 | persist-credentials: false |
| 31 | |
| 32 | - name: Setup Node.js |
| 33 | uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v4.1.0 |
| 34 | with: |
| 35 | node-version: '20' |
| 36 | cache: 'npm' |
| 37 | |
| 38 | - name: Install dependencies |
| 39 | run: npm ci |
| 40 | |
| 41 | - name: Create logs directory |
| 42 | shell: pwsh |
| 43 | run: | |
| 44 | New-Item -ItemType Directory -Force -Path logs | Out-Null |
| 45 | |
| 46 | - name: Run markdown link check |
| 47 | id: link-check |
| 48 | shell: pwsh |
| 49 | run: | |
| 50 | & scripts/linting/Markdown-Link-Check.ps1 |
| 51 | continue-on-error: ${{ inputs.soft-fail }} |
| 52 | |
| 53 | - name: Upload markdown link check results |
| 54 | if: always() |
| 55 | uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v4.4.3 |
| 56 | with: |
| 57 | name: markdown-link-check-results |
| 58 | path: logs/markdown-link-check-results.json |
| 59 | retention-days: 30 |
| 60 | |
| 61 | - name: Check results and fail if needed |
| 62 | if: ${{ !inputs.soft-fail && steps.link-check.outcome == 'failure' }} |
| 63 | shell: pwsh |
| 64 | run: | |
| 65 | Write-Host "Markdown link check failed and soft-fail is false. Failing the job." |
| 66 | exit 1 |
| 67 | |