Skip to content

Commit

Permalink
Update CommentPR.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
amontoison committed Apr 30, 2024
1 parent d63b8b4 commit 55deb60
Showing 1 changed file with 30 additions and 10 deletions.
40 changes: 30 additions & 10 deletions .github/workflows/CommentPR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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
})
}

0 comments on commit 55deb60

Please sign in to comment.