Skip to content

Commit 959a87f

Browse files
committed
Fix empty author name and URL for scheduled jobs
1 parent 2d3113f commit 959a87f

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

.github/actions/send-notification/action.yml

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,25 +30,28 @@ runs:
3030
runNumber=$(echo $json | jq -r .number)
3131
# Determine overall run status (based on all jobs preceding this one)
3232
runStatus=$(echo $json | jq -r '.jobs | map(select(.conclusion != "")) | if all(.conclusion == "success" or .conclusion == "skipped") then "succeeded" elif any(.conclusion == "failure") then "failed" elif any(.conclusion == "cancelled") then "cancelled" else "unsuccessful" end')
33-
# Gather author info
34-
author="${{ github.event.sender.login }}"
35-
authorUrl="${{ github.event.sender.html_url }}"
3633
# **** Templates ****
3734
# Workflow status with link to workflow run
3835
workflowStatus="<${runUrl}|${displayTitle}> ${runStatus}"
3936
# Workflow info with link to all workflow runs for this branch
4037
workflowInfo="<${workflowUrl}|${workflowName}> #${runNumber}"
4138
# Determine run info, with either pull request, commit or manual run info
42-
if [ ! -z "${{ github.event.pull_request.html_url }}" ] ; then
43-
prNumber="${{ github.event.pull_request.number }}"
44-
prUrl="${{ github.event.pull_request.html_url }}"
45-
runInfo="Pull request #<${prUrl}|${prNumber}> opened by <${authorUrl}|${author}>"
46-
elif [ ! -z "${{ github.event.head_commit.url }}" ] ; then
47-
commitUrl="${{ github.event.head_commit.url }}"
48-
shaId=$(echo $json | jq -r .headSha | awk '{ print substr($0, 0, 7) }')
49-
runInfo="Commit <${commitUrl}|${shaId}> pushed by <${authorUrl}|${author}>"
39+
if [ ! -z "${{ github.event.sender.login }}" ] ; then
40+
author="${{ github.event.sender.login }}"
41+
authorUrl="${{ github.event.sender.html_url }}"
42+
if [ ! -z "${{ github.event.pull_request.html_url }}" ] ; then
43+
prNumber="${{ github.event.pull_request.number }}"
44+
prUrl="${{ github.event.pull_request.html_url }}"
45+
runInfo="Pull request #<${prUrl}|${prNumber}> opened by <${authorUrl}|${author}>"
46+
elif [ ! -z "${{ github.event.head_commit.url }}" ] ; then
47+
commitUrl="${{ github.event.head_commit.url }}"
48+
shaId=$(echo $json | jq -r .headSha | awk '{ print substr($0, 0, 7) }')
49+
runInfo="Commit <${commitUrl}|${shaId}> pushed by <${authorUrl}|${author}>"
50+
else
51+
runInfo="Manually run by <${authorUrl}|${author}>"
52+
fi
5053
else
51-
runInfo="Manually run by <${authorUrl}|${author}>"
54+
runInfo="Run via scheduled workflow"
5255
fi
5356
# Build job info messages, joined in single line (multiline breaks GITHUB_ENV)
5457
jobInfo=$(echo $json | jq -r '.jobs | map(select(.conclusion != "")) | map("* <" + .url + "|" + .name + "> was " + .conclusion) | join("\\n")')

0 commit comments

Comments
 (0)