Skip to content

Commit

Permalink
Update CI autocorrect.yml to use NPM command.
Browse files Browse the repository at this point in the history
  • Loading branch information
huacnlee committed Aug 1, 2023
1 parent b64b311 commit 5b511ef
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 6 deletions.
1 change: 1 addition & 0 deletions .autocorrectignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
files/
docs/
!files/zh-cn/
!docs/zh-cn/
36 changes: 31 additions & 5 deletions .github/workflows/autocorrect-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,24 @@ on:
jobs:
lint:
runs-on: ubuntu-latest

permissions:
issues: write
pull-requests: write
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 }}
Expand All @@ -34,11 +48,23 @@ 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]
run: yarn autocorrect --lint --no-diff-bg-color ${{ env.DIFF_DOCUMENTS }}

# https://docs.github.com/en/actions/managing-issues-and-pull-requests/commenting-on-an-issue-when-a-label-is-added
- name: Report Result
if: failure()
uses: peter-evans/create-or-update-comment@v3
with:
args: ${{ env.DIFF_DOCUMENTS }} --lint --no-diff-bg-color
issue-number: ${{ github.event.pull_request.number }}
body: |
[AutoCorrect](https://github.com/huacnlee/autocorrect) lint failure:
```diff
${{ steps.run_lint.outputs.result }}
```
2 changes: 1 addition & 1 deletion docs/zh-cn/translation-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

同样地,如果你对本文的指南有任何改进的建议,请提出问题(issue)或发起 PR。我们对此表示欢迎。下面进入简体中文翻译指南的正文部分。

> 若你对 MDN 上使用的 Markdown 格式不熟悉,请参阅[如何使用 markdown 来撰写文档][]
> 若你对 MDN 上使用的Markdown格式不熟悉,请参阅[如何使用 markdown 来撰写文档][]
## 元数据

Expand Down

0 comments on commit 5b511ef

Please sign in to comment.