From 6aca49faac07ed6ed6dd32c2b8706b6560272362 Mon Sep 17 00:00:00 2001 From: pputman12 Date: Wed, 29 May 2024 06:48:00 -0500 Subject: [PATCH] testing --- .github/workflows/check-linter-error.yml | 50 +++++++++++++++++++ .github/workflows/comment-on-linter-error.yml | 36 +++++++++++++ 2 files changed, 86 insertions(+) create mode 100644 .github/workflows/check-linter-error.yml create mode 100644 .github/workflows/comment-on-linter-error.yml diff --git a/.github/workflows/check-linter-error.yml b/.github/workflows/check-linter-error.yml new file mode 100644 index 0000000..b98face --- /dev/null +++ b/.github/workflows/check-linter-error.yml @@ -0,0 +1,50 @@ +name: Check lint failure + +on: + pull_request: + types: + - opened + branches: + - $default-branch + +concurrency: + group: ${{github.workflow}}-${{github.ref}} + cancel-in-progress: true + +jobs: + comment_on_lint_failure: + name: Comment on lint failure + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@v2 + with: + ref: "refs/pull/${{ github.event.number }}/merge" + - uses: actions/setup-node@v2 + with: + node-version: 14 + cache: yarn + - name: Install + run: yarn --frozen-lockfile + - name: Build + run: yarn build + - name: lint + run: yarn lint + - name: Check dependency versions + run: node scripts/check-dependencies.js + - name: Install website + working-directory: docs/ + run: yarn + - name: Lint website + working-directory: docs/ + run: yarn lint + - name: Save PR number + if: ${{ failure() }} + run: | + mkdir -p ./pr + echo ${{ github.event.number }} > ./pr/NR + - uses: actions/upload-artifact@v4 + if: ${{ failure() }} + with: + name: pr + path: pr/ diff --git a/.github/workflows/comment-on-linter-error.yml b/.github/workflows/comment-on-linter-error.yml new file mode 100644 index 0000000..502a809 --- /dev/null +++ b/.github/workflows/comment-on-linter-error.yml @@ -0,0 +1,36 @@ +name: Comment on the pull request + +# read-write repo token +# access to secrets +on: + workflow_run: + workflows: ["Check lint failure"] + types: + - completed + +jobs: + upload: + runs-on: ubuntu-latest + if: > + github.event.workflow_run.event == 'pull_request' && + github.event.workflow_run.conclusion == 'failure' + steps: + - name: 'Download artifact' + uses: actions/download-artifact@v4 + with: + name: pr + path: pr/ + + - name: 'Comment on PR' + uses: actions/github-script@v6 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + var fs = require('fs'); + var issue_number = Number(fs.readFileSync('./pr/NR')); + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: "Thanks for submitting this PR!\n\nUnfortunately, it has some linter errors, so we can't merge it yet. Can you please fix them?\n\nRunning yarn `lint:fix` in the root of the repository may fix them automatically." + })