-
Notifications
You must be signed in to change notification settings - Fork 1
38 lines (33 loc) · 1.27 KB
/
keep-only-one-comment-on-pr.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
name: keep-only-one-comment-on-pr
on: pull_request
permissions:
pull-requests: write # to enable dependabot to write comment
env:
COMMENT_BODY_IDENTIFIER: test
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Find Comment
uses: peter-evans/find-comment@v2
id: fc
with:
issue-number: ${{ github.event.number }}
body-includes: ${{ env.COMMENT_BODY_IDENTIFIER }}
- name: Delete comment
if: ${{ steps.fc.outputs.comment-id != 0 }}
uses: jungwinter/comment@v1
with:
type: delete
comment_id: ${{ steps.fc.outputs.comment-id }}
token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/github-script@v6
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `<!-- ${process.env.COMMENT_BODY_IDENTIFIER} -->\nAdd \`release\` label if you want to release when this pull request is merged. (${new Date()}) [keep-only-one-comment-on-pr.yml](${{ github.server_url }}/${{ github.repository }}/blob/main/.github/workflows/keep-only-one-comment-on-pr.yml)`
})