docs: Add advanced Git theory section #46
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: 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: Stop and report errors if not master | |
if: github.ref != 'refs/heads/main' && github.ref != 'refs/heads/master' | |
run: | | |
git add -A | |
if ! git diff-index --quiet --cached HEAD --; then | |
echo "Stop." | |
exit 1 | |
fi | |
- 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 "[email protected]" | |
git add -A | |
git commit -m "Auto fix formatting by autocorrect [ci skip]" | |
git push origin HEAD | |
- name: Create Pull Request (if on non-master branch) | |
if: github.ref != 'refs/heads/master' && 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 }}. |