-
Notifications
You must be signed in to change notification settings - Fork 6
50 lines (43 loc) · 2.01 KB
/
notify-push-to-branch.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
name: "8. Notify Slack on branch update"
on:
push:
branches: [ main, qa, develop ]
env:
# Id for the #benefits-vro-devops Slack channel
SLACK_CHANNEL: C04CA47HV96
jobs:
notify_push:
if: github.repository == 'department-of-veterans-affairs/abd-vro'
runs-on: ubuntu-latest
steps:
- name: "Get PR title"
id: get-pr-title
run: |
echo "first_line=$(echo "${{github.event.head_commit.message}}" | head -n 1)" >> $GITHUB_OUTPUT
if [ $(echo "${{github.event.head_commit.message}}" | wc -l) -gt 1 ]; then
echo "multiline=true" >> $GITHUB_OUTPUT
else
echo "multiline=false" >> $GITHUB_OUTPUT
fi
echo "short_sha=${GITHUB_SHA:0:7}" >> $GITHUB_OUTPUT
- name: "Notify Slack"
id: notify-slack
uses: archive/github-actions-slack@v2.6.0
with:
slack-bot-user-oauth-access-token: ${{ secrets.SLACK_BOT_USER_OAUTH_ACCESS_TOKEN }}
slack-channel: ${{ env.SLACK_CHANNEL }}
slack-text: ":git-merge: ${{github.ref_type}} \
<${{github.event.repository.html_url}}/commits/${{github.ref_name}}|${{github.ref_name}}> was pushed \
by `${{github.event.pusher.name}}` using \
<${{github.event.head_commit.url}}|commit ${{steps.get-pr-title.outputs.short_sha}}> \
authored by `${{github.event.head_commit.author.username}}`\n\
`${{ steps.get-pr-title.outputs.first_line }}`"
- name: "Slack thread: Post git commit message"
if: steps.get-pr-title.outputs.multiline == 'true'
# Post in thread to reduce clutter in Slack
uses: archive/github-actions-slack@v2.6.0
with:
slack-bot-user-oauth-access-token: ${{ secrets.SLACK_BOT_USER_OAUTH_ACCESS_TOKEN }}
slack-channel: ${{ env.SLACK_CHANNEL }}
slack-optional-thread_ts: ${{ fromJson(steps.notify-slack.outputs.slack-result).response.message.ts }}
slack-text: "*Commit Message*: \n```${{github.event.head_commit.message}}```"