From 156a2c26cefdc829dd3b48a0720e00d30fabb1b8 Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Fri, 28 Jul 2023 23:54:35 -0700 Subject: [PATCH 1/2] feat(ci): Add Reviewdog for Prettier formatting --- .github/workflows/reviewdog.yml | 45 +++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 .github/workflows/reviewdog.yml diff --git a/.github/workflows/reviewdog.yml b/.github/workflows/reviewdog.yml new file mode 100644 index 00000000000000..731b9cbc21ff76 --- /dev/null +++ b/.github/workflows/reviewdog.yml @@ -0,0 +1,45 @@ +name: reviewdog + +on: + - pull_request + +jobs: + prettier: + # do not run on forks + if: github.repository == 'mdn/content' + name: prettier + 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 + # 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' | xargs) + echo "DIFF_DOCUMENTS=${DIFF_DOCUMENTS}" >> $GITHUB_ENV + + - name: Setup Node.js environment + uses: actions/setup-node@v3 + with: + node-version-file: ".nvmrc" + cache: yarn + + - name: Install all yarn packages + run: yarn --frozen-lockfile + env: + # https://github.com/microsoft/vscode-ripgrep#github-api-limit-note + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Perform linting + run: yarn prettier --ignore-unknown --write ${{ env.DIFF_DOCUMENTS }} + + - name: Submit suggestion + uses: reviewdog/action-suggester@v1 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + tool_name: prettier From fbc7bfa91e494e2dd1d4e3a1701a518f713f0a98 Mon Sep 17 00:00:00 2001 From: "Queen Vinyl Da.i'gyu-Kazotetsu" Date: Sat, 29 Jul 2023 00:17:09 -0700 Subject: [PATCH 2/2] Update .github/workflows/reviewdog.yml Co-authored-by: A1lo --- .github/workflows/reviewdog.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/reviewdog.yml b/.github/workflows/reviewdog.yml index 731b9cbc21ff76..3b5094e9fecf63 100644 --- a/.github/workflows/reviewdog.yml +++ b/.github/workflows/reviewdog.yml @@ -6,7 +6,7 @@ on: jobs: prettier: # do not run on forks - if: github.repository == 'mdn/content' + if: github.repository == 'mdn/translated-content' name: prettier runs-on: ubuntu-latest steps: