Skip to content

Commit 9312988

Browse files
authored
Update discord-head-commit.yml
1 parent d0137cd commit 9312988

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

.github/workflows/discord-head-commit.yml

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,31 @@ jobs:
2424
jq -cs '
2525
(.[0] // []) as $c | (.[1] // null) as $h |
2626
($c + (if $h==null then [] else [$h] end))
27-
| map(select(.id?)) | unique_by(.id) | sort_by(.timestamp // "")
27+
| map(select(.id?))
28+
| unique_by(.id)
29+
| sort_by(.timestamp // "")
2830
' <(printf '%s' "${COMMITS_JSON:-[]}") <(printf '%s' "${HEAD_JSON:-null}")
2931
)"
3032
31-
jq -c '.[] | {id, message, timestamp, author}' <<< "$combined" | while read -r c; do
33+
jq -c '.[] | {id, url, message, timestamp, author}' <<< "$combined" | while read -r c; do
3234
id="$(jq -r '.id // empty' <<< "$c")"
35+
url="$(jq -r '.url // empty' <<< "$c")"
36+
[ -z "$url" ] && url="https://github.com/$REPO/commit/$id"
3337
short="${id:0:7}"
34-
url="https://github.com/$REPO/commit/$id"
3538
msg="$(jq -r '.message // ""' <<< "$c")"
3639
ts="$(jq -r '.timestamp // empty' <<< "$c")"
40+
login="$(jq -r '.author.username // empty' <<< "$c")"
41+
[ -z "$login" ] && login="$ACTOR_FALLBACK"
42+
[ -z "$ts" ] && ts="$(date -Iseconds)"
43+
iso="$(date -u -d "$ts" +'%Y-%m-%dT%H:%M:%SZ')"
3744
3845
jq -n \
39-
--arg login "$(jq -r --arg fb "$ACTOR_FALLBACK" '(.author.username // "") | if length==0 then $fb else . end' <<< "$c")" \
40-
--arg desc "[$short]($url)\n$msg" \
41-
--arg foot "$repo_short - $BRANCH" \
42-
--arg iso "$(date -u -d "${ts:-$(date -Iseconds)}" +'%Y-%m-%dT%H:%M:%SZ')" \
46+
--arg login "$login" \
47+
--arg short "$short" \
48+
--arg url "$url" \
49+
--arg msg "$msg" \
50+
--arg foot "$repo_short - $BRANCH" \
51+
--arg iso "$iso" \
4352
'{
4453
username: "GitHub",
4554
avatar_url: "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png",
@@ -50,7 +59,7 @@ jobs:
5059
url: ("https://github.com/" + $login),
5160
icon_url: ("https://avatars.githubusercontent.com/" + $login)
5261
},
53-
description: $desc,
62+
description: ("[" + $short + "](" + $url + ")" + "\n" + $msg),
5463
footer: { text: $foot },
5564
timestamp: $iso
5665
}]

0 commit comments

Comments
 (0)