-
Notifications
You must be signed in to change notification settings - Fork 0
53 lines (50 loc) · 1.78 KB
/
pullrequest-mattermost.yaml
File metadata and controls
53 lines (50 loc) · 1.78 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
44
45
46
47
48
49
50
51
52
53
name: PullRequest-Mattermost
on:
workflow_call:
secrets:
WEBHOOK:
required: true
pull_request:
types:
- opened
jobs:
notify:
name: Mattermost
runs-on: ubuntu-latest
steps:
- name: Create Mattermost Message
env:
REPOSITORY: ${{ github.repository }}
REPOSITORY_URL: ${{ github.event.pull_request._links.html.html_url }}
ACTION: ${{ github.event.action }}
ACTOR: ${{ github.actor }}
LINK: ${{ github.event.pull_request._links.html.href }}
BODY: ${{ github.event.pull_request.body }}
TITLE: ${{ github.event.pull_request.title }}
shell: bash
run: |
# Use jq to properly construct JSON and escape all special characters
jq -n \
--arg icon ":mermaid:" \
--arg title "$TITLE" \
--arg action "$ACTION" \
--arg repository "$REPOSITORY" \
--arg repository_url "$REPOSITORY_URL" \
--arg author "$ACTOR" \
--arg body "$BODY" \
--arg link "$LINK" \
'{
text: ("## \($icon) New PR!\n### \($title)\n\($action) in: [\($repository)](\($repository_url)) by: **\($author)**\n\n```text\n\($body)\n```\n----\n[pull request](\($link))")
}' > mattermost.json
cat mattermost.json
- name: Read Content
id: getcontent
run: |
echo "payload<<EOF" >> $GITHUB_OUTPUT
cat mattermost.json >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Send Mattermost Message
uses: mattermost/action-mattermost-notify@master
with:
MATTERMOST_WEBHOOK_URL: ${{ secrets.WEBHOOK || secrets.MATTERMOST_WEBHOOK_URL }}
PAYLOAD: ${{ steps.getcontent.outputs.payload }}