|
1
|
name: Notify Slack on OS Bot PRs |
|
2
|
|
|
3
|
on: |
|
4
|
pull_request_target: |
|
5
|
types: [opened] |
|
6
|
|
|
7
|
permissions: {} |
|
8
|
|
|
9
|
jobs: |
|
10
|
notify: |
|
11
|
if: ${{ github.event.pull_request.user.login == 'medusa-os-bot[bot]' }} |
|
12
|
runs-on: ubuntu-latest |
|
13
|
steps: |
|
14
|
- name: Sanitize PR title |
|
15
|
id: pr |
|
16
|
env: |
|
17
|
PR_TITLE: ${{ github.event.pull_request.title }} |
|
18
|
run: | |
|
19
|
TITLE=$(printf '%s' "$PR_TITLE" | tr -d '\000-\037' | tr '<>|&' ' ' | cut -c1-200) |
|
20
|
echo "title=$TITLE" >> "$GITHUB_OUTPUT" |
|
21
|
|
|
22
|
- name: Notify Slack |
|
23
|
uses: slackapi/slack-github-action@v1.23.0 |
|
24
|
env: |
|
25
|
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL_OS_BOT_PRS }} |
|
26
|
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK |
|
27
|
with: |
|
28
|
payload: | |
|
29
|
{ |
|
30
|
"blocks": [ |
|
31
|
{ |
|
32
|
"type": "header", |
|
33
|
"text": { |
|
34
|
"type": "plain_text", |
|
35
|
"text": "New PR opened by medusa-os-bot" |
|
36
|
} |
|
37
|
}, |
|
38
|
{ |
|
39
|
"type": "section", |
|
40
|
"text": { |
|
41
|
"type": "mrkdwn", |
|
42
|
"text": ${{ toJSON(format('<{0}|#{1} — {2}>', github.event.pull_request.html_url, github.event.pull_request.number, steps.pr.outputs.title)) }} |
|
43
|
} |
|
44
|
}, |
|
45
|
{ |
|
46
|
"type": "actions", |
|
47
|
"elements": [ |
|
48
|
{ |
|
49
|
"type": "button", |
|
50
|
"text": { |
|
51
|
"type": "plain_text", |
|
52
|
"text": "View PR" |
|
53
|
}, |
|
54
|
"style": "primary", |
|
55
|
"url": ${{ toJSON(github.event.pull_request.html_url) }} |
|
56
|
} |
|
57
|
] |
|
58
|
} |
|
59
|
] |
|
60
|
} |