11name : Discord notify
2-
32on :
43 push :
54
@@ -19,45 +18,36 @@ jobs:
1918 run : |
2019 set -euo pipefail
2120
22- # Normalize inputs
23- echo "${COMMITS_JSON:-[]}" | jq 'if .==null then [] else . end' > commits.json
24- echo "${HEAD_JSON:-null}" | jq '.' > head.json
21+ echo "${COMMITS_JSON:-[]}" > commits.json
22+ echo "${HEAD_JSON:-null}" > head.json
2523
2624 # Combine commits + head_commit, de-dup by id, sort by timestamp
2725 jq -cs '
28- (.[0] // []) + (if .[1]==null or .[1]=={} then [] else [.[1]] end)
26+ (.[0] // []) as $c |
27+ (.[1] // null) as $h |
28+ ($c + (if $h==null then [] else [$h] end))
2929 | map(select(.id?))
3030 | unique_by(.id)
3131 | sort_by(.timestamp // "")
3232 ' commits.json head.json > list.json
3333
3434 repo_short="$(awk -F/ '{print ($2?$2:$0)}' <<< "$REPO")"
3535
36- jq -c '.[] | {id, message, timestamp, author}' list.json | while read -r c; do
36+ jq -c '.[] | {message, timestamp, author}' list.json | while read -r c; do
3737 msg="$(jq -r '.message // ""' <<< "$c")"
3838 ts="$(jq -r '.timestamp // empty' <<< "$c")"
3939 login="$(jq -r '.author.username // empty' <<< "$c")"
4040 [ -z "$login" ] && login="$ACTOR_FALLBACK"
4141
42- # Time handling
42+ # Fallback-safe time; Discord timestamp must be UTC ISO
4343 if [ -z "$ts" ] || ! date -d "$ts" >/dev/null 2>&1; then ts="$(date -Iseconds)"; fi
44- c_date="$(date -u -d "$ts" +"%Y-%m-%d")"
45- n_date="$(date -u +"%Y-%m-%d")"
46- time_str="$(date -d "$ts" +"%-H:%M")"
47- if [ "$c_date" = "$n_date" ]; then
48- foot_extra="Today $time_str"
49- else
50- date_str="$(date -d "$ts" +"%d/%m/%Y")"
51- foot_extra="$date_str $time_str"
52- fi
5344 iso_utc="$(date -u -d "$ts" +"%Y-%m-%dT%H:%M:%SZ")"
45+ time_str="$(date -d "$ts" +"%-H:%M")"
5446
5547 jq -n \
5648 --arg login "$login" \
5749 --arg msg "$msg" \
58- --arg repo "$repo_short" \
59- --arg branch "$BRANCH" \
60- --arg foot "$repo_short - $BRANCH • $foot_extra" \
50+ --arg foot "$repo_short - $BRANCH • $time_str" \
6151 --arg iso "$iso_utc" \
6252 '{
6353 username: "GitHub",
0 commit comments