Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: add autocorrect-lint workflow for zh-CN #4191

Merged
merged 13 commits into from
Jul 26, 2023
Merged
3 changes: 3 additions & 0 deletions .autocorrectignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
files/
huacnlee marked this conversation as resolved.
Show resolved Hide resolved
docs/
!files/zh-cn/
bsmth marked this conversation as resolved.
Show resolved Hide resolved
4 changes: 4 additions & 0 deletions .autocorrectrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
textRules:
一二三,四五六.七八九: 0
一二三,四五六,七八九,一二三,四五六,七八九: 0
9.9亿: 0
35 changes: 35 additions & 0 deletions .github/workflows/autocorrect-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: AutoCorrect Lint

huacnlee marked this conversation as resolved.
Show resolved Hide resolved
on:
pull_request:
branches:
- main
huacnlee marked this conversation as resolved.
Show resolved Hide resolved
paths:
- "files/zh-cn/**"
huacnlee marked this conversation as resolved.
Show resolved Hide resolved

jobs:
lint:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Get changed files
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BASE_SHA: ${{ github.event.pull_request.base.sha }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
run: |
# Use the GitHub API to get the list of changed files
bsmth marked this conversation as resolved.
Show resolved Hide resolved
# documenation: https://docs.github.com/rest/commits/commits#compare-two-commits
DIFF_DOCUMENTS=$(gh api repos/{owner}/{repo}/compare/${{ env.BASE_SHA }}...${{ env.HEAD_SHA }} \
--jq '.files | .[] | select(.status|IN("added", "modified", "renamed", "copied", "changed")) | .filename')
# filter out files that are not markdown
DIFF_DOCUMENTS=$(echo "${DIFF_DOCUMENTS}" | egrep -i "^files/zh-cn/" | xargs)
echo "DIFF_DOCUMENTS=${DIFF_DOCUMENTS}" >> $GITHUB_ENV

- name: AutoCorrect changed content
if: ${{ env.DIFF_DOCUMENTS }}
uses: huacnlee/[email protected]
with:
args: ${{ env.DIFF_DOCUMENTS }} --lint