-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d63b8b4
commit 55deb60
Showing
1 changed file
with
30 additions
and
10 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,8 +13,8 @@ jobs: | |
upload: | ||
runs-on: ubuntu-latest | ||
if: > | ||
${{ github.event.workflow_run.event == 'pull_request' && | ||
github.event.workflow_run.conclusion == 'success' }} | ||
github.event.workflow_run.event == 'pull_request' && | ||
github.event.workflow_run.conclusion == 'success' | ||
steps: | ||
- name: 'Download artifact' | ||
uses: actions/[email protected] | ||
|
@@ -39,16 +39,36 @@ jobs: | |
- run: unzip pr.zip | ||
|
||
- name: 'Comment on PR' | ||
uses: actions/github-script@v3 | ||
uses: actions/github-script@v6 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
script: | | ||
var fs = require('fs'); | ||
var issue_number = Number(fs.readFileSync('./NR')); | ||
var msg = fs.readFileSync('./MSG', 'utf8'); | ||
await github.issues.createComment({ | ||
var fs = require('fs') | ||
var issue_number = Number(fs.readFileSync('./NR')) | ||
var msg = fs.readFileSync('./MSG', 'utf8') | ||
// Get the existing comments. | ||
const {data: comments} = await github.rest.issues.listComments({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
issue_number: issue_number, | ||
body: msg | ||
}); | ||
issue_number: issue_number | ||
}) | ||
// Find any comment already made by the bot. | ||
const botComment = comments.find(comment => comment.user.id === 41898282) | ||
if (botComment) { | ||
await github.rest.issues.updateComment({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
comment_id: botComment.id, | ||
body: msg | ||
}) | ||
} else { | ||
await github.rest.issues.createComment({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
issue_number: issue_number, | ||
body: msg | ||
}) | ||
} |