Skip to content

Commit

Permalink
Fix Reviewdog workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
queengooborg committed Jul 29, 2023
1 parent c9bfaa5 commit be72d57
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion .github/workflows/reviewdog.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: reviewdog

on:
- pull_request
- pull_request

jobs:
prettier:
Expand All @@ -12,6 +12,20 @@ jobs:
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
# 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/.*\.md$" | xargs)
echo "DIFF_DOCUMENTS=${DIFF_DOCUMENTS}" >> $GITHUB_ENV
- name: Setup Node.js environment
uses: actions/setup-node@v3
with:
Expand All @@ -24,7 +38,11 @@ jobs:
# https://github.com/microsoft/vscode-ripgrep#github-api-limit-note
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Perform linting
run: yarn prettier -w "${{ env.DIFF_DOCUMENTS }}"

- name: Submit suggestion
uses: reviewdog/action-suggester@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
tool_name: prettier

0 comments on commit be72d57

Please sign in to comment.