Skip to content

update actions

update actions #48

name: Auto FormatFormat Documents
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
format:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: "16"
- name: Install Prettier
run: |
npm install --save-dev prettier
- name: Format YAML and Markdown files
run: |
npx prettier --write "**/*.yml" "**/*.md"
- name: Check for changes
id: check_changes
run: |
git diff --exit-code || echo "has_diff=true" >> $GITHUB_OUTPUT
- name: Commit changes
if: steps.check_changes.outputs.has_diff == 'true'
run: |
git config --local user.name "github-actions"
git config --local user.email "[email protected]"
git add .
git commit -m "Format YAML and Markdown files with Prettier" || echo "No changes to commit"
git push origin HEAD:main