diff --git a/.github/workflows/discord-feed.yml b/.github/workflows/discord-feed.yml index 6db3c71f..a234196e 100644 --- a/.github/workflows/discord-feed.yml +++ b/.github/workflows/discord-feed.yml @@ -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: @@ -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' \ @@ -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"