Comment on the pull request #17
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Comment on the pull request | |
# read-write repo token | |
# access to secrets | |
on: | |
workflow_run: | |
workflows: ["Check lint failure"] | |
types: | |
- completed | |
jobs: | |
comment: | |
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-number | |
path: pr | |
repository: ${{ github.context.repository }} | |
run-id: ${{github.event.workflow_run.id }} | |
- name: Display structure of downloaded files | |
run: ls -R pr | |
- name: Catfile | |
run: cat pr/pr-number | |
- 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/pr-number')); | |
github.rest.issues.createComment({ | |
issue_number: 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." | |
}) |