-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update CI autocorrect.yml to use NPM command.
- Loading branch information
Showing
3 changed files
with
25 additions
and
7 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ | |
files/ | ||
docs/ | ||
!files/zh-cn/ | ||
!docs/zh-cn/ |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,10 +19,21 @@ on: | |
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Setup Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version-file: ".nvmrc" | ||
cache: yarn | ||
|
||
- name: Install NPM | ||
run: | | ||
yarn --frozen-lockfile | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Get changed files | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
@@ -34,11 +45,17 @@ jobs: | |
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) | ||
DIFF_DOCUMENTS=$(echo "${DIFF_DOCUMENTS}" | egrep -i "^(files|docs)/zh-cn/" | xargs) | ||
echo "DIFF_DOCUMENTS=${DIFF_DOCUMENTS}" >> $GITHUB_ENV | ||
- name: AutoCorrect changed content | ||
- name: AutoCorrect lint changed content | ||
id: run_lint | ||
if: ${{ env.DIFF_DOCUMENTS }} | ||
uses: huacnlee/[email protected] | ||
with: | ||
args: ${{ env.DIFF_DOCUMENTS }} --lint --no-diff-bg-color | ||
run: yarn autocorrect --lint --no-diff-bg-color ${{ env.DIFF_DOCUMENTS }} | ||
|
||
- name: Report Result to Issue comment | ||
if: failure() | ||
run: | | ||
gh issue comment ${{ github.event.pull_request.number }} --body "AutoCorrect lint failure: \n\n```diff\n${{ steps.run_lint.outputs.result }}\n```" | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains 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