Skip to content

Comment on the pull request #21

Comment on the pull request

Comment on the pull request #21

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.repository }}
run-id: ${{github.event.workflow_run.id }}
github-token: ${{ secrets.GITHUB_TOKEN }}
- 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."
})