-
Notifications
You must be signed in to change notification settings - Fork 2
43 lines (40 loc) · 1.99 KB
/
notify.yml
File metadata and controls
43 lines (40 loc) · 1.99 KB
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
name: Notify
permissions:
contents: none
on:
push:
branches:
- main
- production
jobs:
Notify:
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v6
id: action-message
with:
script: |
const commits = ${{ toJSON(github.event.commits) }}
const repo = "${{ github.repository }}"
const pusher = "${{ github.event.pusher.name }}"
const branch = "${{ github.event.ref }}"
const numberOfCommits = commits.length;
const forced = ${{ github.event.forced}};
const forcedText = forced ? ' (force)' : '';
const repoUrl = `https://github.com/${repo}`;
let actionMessage = `<${repoUrl}|${repo}>: ${pusher}${forcedText} pushed ${numberOfCommits} new commits to ${branch}:\n`;
for (const commit of commits) {
let shortHash = commit.id.slice(0, 7);
let commitFirstLine = commit.message.split('\n')[0];
actionMessage += `- <${commit.url}|${shortHash}>: ${commitFirstLine}`;
actionMessage += '\n';
}
actionMessage = actionMessage.trim();
console.log(actionMessage);
return actionMessage;
- name: Notify
if: ${{ always() }} # Use always to ensure that the notification is also send on failure of former steps
uses: teknatha136/actions-google-chat-text-message@ecec1de3697db2ae67623ed3b4de15bb85d6cac3
with:
google-chat-webhook: '${{ secrets.GOOGLE_CHAT_WEBHOOK_URL }}'
text-message: ${{ steps.action-message.outputs.result }}