Skip to content

chore: align badges and workflows with org template #2

chore: align badges and workflows with org template

chore: align badges and workflows with org template #2

name: Validate and Fix Markdown
on:
pull_request:
branches:
- main
concurrency:
group: pr-branch-maintenance-${{ github.event.pull_request.head.ref || github.ref_name }}
cancel-in-progress: false
permissions:
contents: write
pull-requests: write
jobs:
validate-and-fix-markdown:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install Markdown linter
run: npm install -g markdownlint-cli
- name: Lint and fix Markdown files
run: markdownlint "**/*.md" --fix --config .github/.markdownlint.json
- name: Validate standard Markdown header
id: validate-header
continue-on-error: true
run: python .github/scripts/validate_markdown_header.py
- name: Configure Git
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
- name: Commit and rebase changes
env:
PR_BRANCH: ${{ github.head_ref || github.ref_name }}
TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git add -A
if git diff --staged --quiet; then
echo "No changes to commit"
exit 0
fi
git commit -m "Fix Markdown syntax issues"
git remote set-url origin https://x-access-token:${TOKEN}@github.com/${{ github.repository }}
for attempt in 1 2 3; do
git fetch origin "$PR_BRANCH"
git rebase "origin/$PR_BRANCH"
if git push origin HEAD:"$PR_BRANCH"; then
exit 0
fi
done
echo "Failed to push branch updates after 3 attempts."
exit 1
- name: Fail if standard Markdown header validation failed
if: steps.validate-header.outcome == 'failure'
run: |
echo "Standard Markdown header validation failed."
exit 1