Skip to content
This repository has been archived by the owner on Oct 14, 2023. It is now read-only.

Update README.md

Update README.md #810

name: Format and Lint Code
on: push
jobs:
format_and_lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install pnpm
run: npm install -g pnpm
- name: Install node modules
run: pnpm install
- name: Prettier Format
run: pnpm run format
- name: Config git
run: |
git config user.name 'github-actions'
git config user.email 'github-actions@github.com'
- name: Commit and push
run: |
if [[ -n $(git status --porcelain) ]]
then
git add .
git commit -m 'chore: format code'
git push
else
echo "Nothing to commit."
fi
- name: ESLint Check
id: check-code
run: |
check_output=$(pnpm run --silent check || :)
check_failed=$([[ -z "$check_output" ]] && echo 'false' || echo 'true')
check_output=$(echo -e "\`\`\`${check_output}\n\`\`\`")
check_output="${check_output//'%'/'%25'}"
check_output="${check_output//$'\n'/'%0A'}"
check_output="${check_output//$'\r'/'%0D'}"
echo check_output="$check_output" >> $GITHUB_OUTPUT
echo check_failed="$check_failed" >> $GITHUB_OUTPUT
- name: Comment if check failed
uses: peter-evans/commit-comment@v2
if: ${{ 'true' == steps.check-code.outputs.check_failed }}
with:
body: ${{ steps.check-code.outputs.check_output }}
- name: Error if check failed
if: ${{ 'true' == steps.check-code.outputs.check_failed }}
run: exit -1