docs:Add examples for CI/CD,add reset-diff-and-commit,Corrected previ… #59
This file contains 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: Lint | |
on: | |
push: | |
branches: | |
- '*' | |
pull_request: | |
branches: | |
- '*' | |
paths: | |
- '**/*.md' # Only run on Markdown file changes | |
jobs: | |
markdown-lint: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # Fetch full history to allow Git operations | |
- name: Lint | |
continue-on-error: true | |
run: | | |
curl -fsSL https://raw.githubusercontent.com/huacnlee/autocorrect/main/install | sh | |
autocorrect --fix | |
- name: Check for changes | |
id: check_changes | |
run: | | |
if git diff --quiet; then | |
echo "No changes detected." | |
echo "has_changes=false" >> "$GITHUB_OUTPUT" | |
else | |
echo "Changes detected. Preparing to commit..." | |
echo "has_changes=true" >> "$GITHUB_OUTPUT" | |
fi | |
- name: Commit and push changes | |
if: steps.check_changes.outputs.has_changes == 'true' | |
run: | | |
git config --global user.name "github-actions" | |
git config --global user.email "github-actions@github.com" | |
git add -A | |
git commit -m "Auto fix formatting by autocorrect [ci skip]" | |
git push origin HEAD | |
- name: Create Pull Request | |
if: steps.check_changes.outputs.has_changes == 'true' | |
uses: peter-evans/create-pull-request@v6 | |
with: | |
commit-message: "Auto fix formatting by autocorrect [ci skip]" | |
branch: auto-fix-${{ github.run_number }} | |
delete-branch: true | |
title: "Auto fix formatting by autocorrect" | |
body: | | |
This PR contains automatic fixes by the `autocorrect` tool. | |
Generated by GitHub Actions run ${{ github.run_number }}. |