-
Notifications
You must be signed in to change notification settings - Fork 4
84 lines (73 loc) · 2.85 KB
/
notify-pr-status.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
name: Notify PR Status
on:
pull_request:
types: [opened, closed]
branches:
- main
pull_request_review:
types: [submitted]
env:
ACTOR: ${{ github.actor }}
PR_NAME: ${{ github.event.pull_request.title }}
PR_BRANCH_NAME: ${{ github.event.pull_request.head.ref }}
PR_URL: ${{ github.event.pull_request.html_url }}
PR_AUTHOR: ${{ github.event.pull_request.user.login }}
PR_AUTHOR_URL: ${{ github.event.pull_request.user.html_url }}
PR_APPROVER: ${{ github.event.review.user.login }}
REPO: ${{ github.repository }}
REPO_URL: ${{ github.event.repository.html_url }}
jobs:
notify-opened:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request' && github.event.action == 'opened'
steps:
- uses: actions/checkout@v4
- name: Generate message
id: generate-message
run: |
bash templates/slack-notify-pr-opened.tpl
cat slack_message | awk '{printf "%s\\n", $0}' > slack_message.stripped
BODY=$(cat slack_message.stripped)
echo "payload=$BODY" >> $GITHUB_OUTPUT
- name: Post to Slack
uses: rise8-us/cato-playbook/.github/actions/post-to-slack@main
with:
channel-id: ${{ vars.SLACK_CHANNEL_ID }}
message: ${{ steps.generate-message.outputs.payload }}
slack-bot-token: ${{ secrets.SLACK_BOT_TOKEN }}
notify-approved:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request_review' && github.event.review.state == 'approved'
steps:
- uses: actions/checkout@v4
- name: Generate message
id: generate-message
run: |
bash templates/slack-notify-pr-approved.tpl
cat slack_message | awk '{printf "%s\\n", $0}' > slack_message.stripped
BODY=$(cat slack_message.stripped)
echo "payload=$BODY" >> $GITHUB_OUTPUT
- name: Post to Slack
uses: rise8-us/cato-playbook/.github/actions/post-to-slack@main
with:
channel-id: ${{ vars.SLACK_CHANNEL_ID }}
message: ${{ steps.generate-message.outputs.payload }}
slack-bot-token: ${{ secrets.SLACK_BOT_TOKEN }}
notify-closed:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged
steps:
- uses: actions/checkout@v4
- name: Generate message
id: generate-message
run: |
bash templates/slack-notify-pr-closed.tpl
cat slack_message | awk '{printf "%s\\n", $0}' > slack_message.stripped
BODY=$(cat slack_message.stripped)
echo "payload=$BODY" >> $GITHUB_OUTPUT
- name: Post to Slack
uses: rise8-us/cato-playbook/.github/actions/post-to-slack@main
with:
channel-id: ${{ vars.SLACK_CHANNEL_ID }}
message: ${{ steps.generate-message.outputs.payload }}
slack-bot-token: ${{ secrets.SLACK_BOT_TOKEN }}