proofreading #58
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: proofreading | |
on: | |
schedule: | |
- cron: "0 23 */7 * *" | |
workflow_dispatch: | |
jobs: | |
Proofreading: | |
if: github.repository_owner == 'labex-labs' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 1 | |
- name: Formatting files | |
run: | | |
current_date=$(date +%s) && last_commit_date=$(git log -1 --format="%ct") && days_diff=$(($(($current_date - $last_commit_date)) / 86400)) && [ "$days_diff" -gt "7" ] && echo "最后一次提交已超过 7 天" && exit 1 || echo "最后一次提交未超过 7 天" | |
npm i -D prettier prettier-plugin-sh | |
pip install black | |
echo "dependencies installed" | |
npx prettier --log-level silent --write **/*.md | |
echo "markdown files formatted" | |
npx prettier --log-level silent --write **/*.json | |
echo "json files formatted" | |
npx prettier --log-level error --write **/*.sh | |
echo "shell files formatted" | |
python -m black -q **/*.py | |
echo "python files formatted" | |
continue-on-error: true | |
- name: Git commit | |
uses: stefanzweifel/git-auto-commit-action@v4 | |
with: | |
commit_message: formatting files | |
branch: ${{ github.head_ref }} |