From 31572b178dddca552529347c2cb7b79d493f2b19 Mon Sep 17 00:00:00 2001 From: Jason Lee Date: Tue, 1 Aug 2023 09:44:08 +0800 Subject: [PATCH] Update CI autocorrect.yml to use NPM command. --- .autocorrectignore | 1 + .github/workflows/autocorrect-lint.yml | 20 +++++++++++++++----- docs/zh-cn/translation-guide.md | 2 +- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/.autocorrectignore b/.autocorrectignore index cabe9364ee1033..857c33a29100f5 100644 --- a/.autocorrectignore +++ b/.autocorrectignore @@ -5,3 +5,4 @@ files/ docs/ !files/zh-cn/ +!docs/zh-cn/ \ No newline at end of file diff --git a/.github/workflows/autocorrect-lint.yml b/.github/workflows/autocorrect-lint.yml index 5c28e32aaf0d37..c4c458808d8ae7 100644 --- a/.github/workflows/autocorrect-lint.yml +++ b/.github/workflows/autocorrect-lint.yml @@ -23,6 +23,18 @@ jobs: 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 +46,9 @@ 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 if: ${{ env.DIFF_DOCUMENTS }} - uses: huacnlee/autocorrect-action@v2.6.2 - with: - args: ${{ env.DIFF_DOCUMENTS }} --lint --no-diff-bg-color + run: yarn autocorrect --lint --no-diff-bg-color ${{ env.DIFF_DOCUMENTS }} diff --git a/docs/zh-cn/translation-guide.md b/docs/zh-cn/translation-guide.md index a209106b0eaf69..a6017dd73bfa1b 100644 --- a/docs/zh-cn/translation-guide.md +++ b/docs/zh-cn/translation-guide.md @@ -4,7 +4,7 @@ 同样地,如果你对本文的指南有任何改进的建议,请提出问题(issue)或发起 PR。我们对此表示欢迎。下面进入简体中文翻译指南的正文部分。 -> 若你对 MDN 上使用的 Markdown 格式不熟悉,请参阅[如何使用 markdown 来撰写文档][]。 +> 若你对 MDN 上使用的Markdown格式不熟悉,请参阅[如何使用 markdown 来撰写文档][]。 ## 元数据