microsoft/hve-core
Publicmirrored fromhttps://github.com/microsoft/hve-coreAvailable
.github/workflows/markdown-lint.yml
80lines · modecode
| 1 | name: Markdown Lint |
| 2 | |
| 3 | on: |
| 4 | workflow_call: |
| 5 | inputs: |
| 6 | soft-fail: |
| 7 | description: 'Whether to continue on markdown lint violations' |
| 8 | required: false |
| 9 | type: boolean |
| 10 | default: false |
| 11 | |
| 12 | # Minimal permissions |
| 13 | permissions: |
| 14 | contents: read |
| 15 | |
| 16 | jobs: |
| 17 | markdown-lint: |
| 18 | name: Markdown Lint |
| 19 | runs-on: ubuntu-latest |
| 20 | permissions: |
| 21 | contents: read |
| 22 | steps: |
| 23 | - name: Harden Runner |
| 24 | uses: step-security/harden-runner@95d9a5deda9de15063e7595e9719c11c38c90ae2 # v2.10.2 |
| 25 | with: |
| 26 | egress-policy: audit |
| 27 | |
| 28 | - name: Checkout code |
| 29 | uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v4.2.2 |
| 30 | with: |
| 31 | persist-credentials: false |
| 32 | |
| 33 | - name: Setup Node.js |
| 34 | uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v4.1.0 |
| 35 | with: |
| 36 | node-version: '20' |
| 37 | cache: 'npm' |
| 38 | |
| 39 | - name: Install dependencies |
| 40 | run: npm ci |
| 41 | |
| 42 | - name: Run markdown lint |
| 43 | id: markdown-lint |
| 44 | run: | |
| 45 | npm run lint:md > markdown-lint-output.txt 2>&1 || echo "MARKDOWN_LINT_FAILED=true" >> $GITHUB_ENV |
| 46 | cat markdown-lint-output.txt |
| 47 | continue-on-error: true |
| 48 | |
| 49 | - name: Create annotations |
| 50 | if: env.MARKDOWN_LINT_FAILED == 'true' |
| 51 | run: | |
| 52 | echo "::warning::Markdown lint found violations. Review markdown-lint-output.txt artifact for details." |
| 53 | |
| 54 | - name: Upload markdown lint results |
| 55 | if: always() |
| 56 | uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v4.4.3 |
| 57 | with: |
| 58 | name: markdown-lint-results |
| 59 | path: markdown-lint-output.txt |
| 60 | retention-days: 30 |
| 61 | |
| 62 | - name: Add job summary |
| 63 | if: always() |
| 64 | run: | |
| 65 | echo "## Markdown Lint Results" >> $GITHUB_STEP_SUMMARY |
| 66 | if [ "${{ env.MARKDOWN_LINT_FAILED }}" == "true" ]; then |
| 67 | echo "❌ **Status**: Failed" >> $GITHUB_STEP_SUMMARY |
| 68 | echo "" >> $GITHUB_STEP_SUMMARY |
| 69 | echo "Markdown linting violations detected. Please review the artifact for details." >> $GITHUB_STEP_SUMMARY |
| 70 | else |
| 71 | echo "✅ **Status**: Passed" >> $GITHUB_STEP_SUMMARY |
| 72 | echo "" >> $GITHUB_STEP_SUMMARY |
| 73 | echo "No markdown linting violations detected." >> $GITHUB_STEP_SUMMARY |
| 74 | fi |
| 75 | |
| 76 | - name: Fail job if violations found |
| 77 | if: env.MARKDOWN_LINT_FAILED == 'true' && !inputs.soft-fail |
| 78 | run: | |
| 79 | echo "Markdown lint failed" |
| 80 | exit 1 |
| 81 | |