File tree Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -39,7 +39,8 @@ COMMIT_URL="https://github.com/$GITHUB_REPOSITORY/commit/$GITHUB_SHA"
39
39
# Then this sed command returns: feature/example-branch
40
40
BRANCH_NAME=" $( echo $GITHUB_REF | sed ' s/^[^/]*\/[^/]*\///g' ) "
41
41
REPO_URL=" https://github.com/$GITHUB_REPOSITORY "
42
- BRANCH_URL=" $REPO_URL /tree/$BRANCH_NAME "
42
+ BRANCH_OR_PR=" Branch"
43
+ BRANCH_OR_PR_URL=" $REPO_URL /tree/$BRANCH_NAME "
43
44
ACTION_URL=" $COMMIT_URL /checks"
44
45
45
46
if [ " $AUTHOR_NAME " == " $COMMITTER_NAME " ]; then
48
49
CREDITS=" $AUTHOR_NAME authored & $COMMITTER_NAME committed"
49
50
fi
50
51
52
+ if [ " $GITHUB_EVENT_NAME " == " pull_request" ]; then
53
+ BRANCH_OR_PR=" Pull Request"
54
+
55
+ PR_NUM=$( echo $BRANCH_NAME | sed ' s/^\([0-9]\+\).*/\1/g' )
56
+ BRANCH_OR_PR_URL=" $REPO_URL /pull/$PR_NUM "
57
+ BRANCH_NAME=" #${PR_NUM} "
58
+ fi
59
+
51
60
TIMESTAMP=$( date --utc +%FT%TZ)
52
61
WEBHOOK_DATA=' {
53
62
"username": "",
@@ -69,8 +78,8 @@ WEBHOOK_DATA='{
69
78
"inline": true
70
79
},
71
80
{
72
- "name": "Branch ",
73
- "value": "' " [\` ${BRANCH_NAME} \` ](${BRANCH_URL } )" ' ",
81
+ "name": "' " $BRANCH_OR_PR " ' ",
82
+ "value": "' " [\` ${BRANCH_NAME} \` ](${BRANCH_OR_PR_URL } )" ' ",
74
83
"inline": true
75
84
}
76
85
],
Original file line number Diff line number Diff line change @@ -7,4 +7,5 @@ export GITHUB_REPOSITORY="DiscordHooks/github-actions-discord-webhook"
7
7
export GITHUB_REF=" refs/heads/feature/example-branch"
8
8
export HOOK_OS_NAME=" Windows"
9
9
export WORKFLOW_NAME=" Main Pipeline"
10
+ export GITHUB_EVENT_NAME = " pull_request" # Could also be push, ext.
10
11
./send.sh Success $DISCORD_URL
You can’t perform that action at this time.
0 commit comments