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: Validate and Fix Markdown | |
on: | |
pull_request: | |
branches: | |
- main | |
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 | |
ref: ${{ github.head_ref || github.ref_name }} | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '16' | |
- 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: 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 merge changes | |
env: | |
PR_BRANCH: ${{ github.head_ref || github.ref_name }} | |
GIT_AUTHOR_NAME: github-actions[bot] | |
GIT_AUTHOR_EMAIL: github-actions[bot]@users.noreply.github.com | |
GIT_COMMITTER_NAME: github-actions[bot] | |
GIT_COMMITTER_EMAIL: github-actions[bot]@users.noreply.github.com | |
run: | | |
# Ensure we're on the correct branch | |
git switch -c "$PR_BRANCH" || git switch "$PR_BRANCH" | |
# Stage and commit changes if any | |
git add -A | |
git diff --staged --quiet || git commit -m "Fix Markdown syntax issues" | |
# Pull and merge existing changes | |
git pull origin "$PR_BRANCH" --no-rebase | |
# Push all changes | |
git push origin "$PR_BRANCH" |