forked from Gamer025/CodeOwnersParser
-
Notifications
You must be signed in to change notification settings - Fork 1
/
example-comment-workflow.yml
52 lines (43 loc) · 1.86 KB
/
example-comment-workflow.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#Example worflow for Gamer025/CodeOwnersParser that posts or edits a comment
name: Codeowner Notification
# Controls when the workflow will run
on:
pull_request:
branches: [ main ]
jobs:
notify-comment:
runs-on: ubuntu-latest
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- name: CodeOwnersParser
id: CodeOwnersParser
uses: Gamer025/CodeOwnersParser@v1
with:
#We don't specify the botname so we always get all owners returned, because we are replacing the existing comment
#If we were appending or always posting a new comment botname should be specified
prefix: 'Notifying code owners: '
- name: Check if already commented
uses: peter-evans/find-comment@v1
id: find-comment
with:
issue-number: ${{ github.event.number }}
comment-author: 'github-actions[bot]'
body-includes: 'Notifying code owners: '
#If no existing comment exists create a new one if there were any owners found
- name: Create new comment
if: steps.find-comment.outputs.comment-id == '' && steps.CodeOwnersParser.outputs.owners != ''
uses: peter-evans/create-or-update-comment@v1
with:
issue-number: ${{ github.event.number }}
body: |
${{ steps.CodeOwnersParser.outputs.owners-formatted }}
#If existing comment was found replace it
- name: Update existing comment
if: steps.find-comment.outputs.comment-id != '' && steps.CodeOwnersParser.outputs.owners != ''
uses: peter-evans/create-or-update-comment@v1
with:
comment-id: ${{ steps.find-comment.outputs.comment-id }}
edit-mode: replace
body: |
${{ steps.CodeOwnersParser.outputs.owners-formatted }}