Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions .github/workflows/discord-feed.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Posts what matters on GitHub to the WrongGPU Discord (#github-feed): merged pull requests with a short summary and
# their milestone's progress, new issues from the community, and published releases. Nothing else (no pushes, no
# opened or edited pull requests). It never checks out pull request code; it only reads the event and the milestone.
# The digest job posts a summary written elsewhere (workflow_dispatch with a message; maintainers only).
# The digest job posts a summary written elsewhere (workflow_dispatch with a message; maintainers only) and pings @here.
name: Discord feed

on:
Expand Down Expand Up @@ -42,7 +42,7 @@ jobs:
run: |
set -euo pipefail
[ -n "$WEBHOOK" ] || { echo "no webhook secret"; exit 0; }
ev="$GITHUB_EVENT_PATH"
ev="$GITHUB_EVENT_PATH"; ping=""
# first real paragraph of a body: no headings, comments, checklists or bot lines; 350 characters at most
summary() { jq -r "$1 // \"\"" "$ev" | tr -d '\r' | sed -e '/^<!--/,/-->/d' -e '/^#/d' -e '/^- \[[ x]\]/d' \
-e '/^Signed-off-by:/d' -e '/^Co-Authored-By:/d' -e '/^Refs\? #/d' -e '/^Fixes #/d' -e '/^Closes #/d' \
Expand All @@ -68,10 +68,12 @@ jobs:
title="Released: $(jq -r '.release.name // .release.tag_name' "$ev")"
url=$(jq -r .release.html_url "$ev"); desc=$(summary .release.body); color=3447003; ms="" ;;
workflow_dispatch)
title="$DIGEST_TITLE"; url="https://github.com/$REPO"; desc=$(printf '%s' "$DIGEST_MESSAGE" | cut -c1-4000); color=10181046; ms="" ;;
title="$DIGEST_TITLE"; url="https://github.com/$REPO"; desc=$(printf '%s' "$DIGEST_MESSAGE" | cut -c1-4000); color=10181046; ms=""; ping="@here" ;;
esac
payload=$(jq -n --arg t "${title:0:250}" --arg u "$url" --arg d "$desc" --arg m "$ms" --argjson c "$color" \
'{username:"GitHub", embeds:[{title:$t, url:$u, description:$d, color:$c,
# only the digest pings @here; merged pull requests, issues and releases post silently
payload=$(jq -n --arg t "${title:0:250}" --arg u "$url" --arg d "$desc" --arg m "$ms" --argjson c "$color" --arg p "$ping" \
'{username:"GitHub", content:$p, allowed_mentions:{parse:(if $p=="" then [] else ["everyone"] end)},
embeds:[{title:$t, url:$u, description:$d, color:$c,
fields:(if $m=="" then [] else [{name:"Milestone", value:$m, inline:true}] end)}]}')
curl -fsS -X POST -H "Content-Type: application/json" --data "$payload" "$WEBHOOK" >/dev/null
echo "posted: $title"
Loading