Skip to content

fix(spotlight): read back the calculator result in any language #260

fix(spotlight): read back the calculator result in any language

fix(spotlight): read back the calculator result in any language #260

name: Announce commits on Discord
on:
push:
branches: [dev]
jobs:
announce:
runs-on: ubuntu-latest
steps:
- name: Post commits to Discord
env:
WEBHOOK_URL: ${{ secrets.COMMITS_WEBHOOK_URL }}
ICON: https://raw.githubusercontent.com/XeldarAlz/FFXIV-Aetherphone/dev/src/Aetherphone/Images/Icon.png
run: |
set -euo pipefail
if [ -z "${WEBHOOK_URL:-}" ]; then
echo 'COMMITS_WEBHOOK_URL not set; skipping the announcement.'
exit 0
fi
# release.yml and update-issue-template-versions.yml push their bumps
# with a PAT, and PAT pushes do cascade-trigger this workflow, so drop
# the bot's own commits instead of announcing them.
count=$(jq '[.commits[] | select(.author.name != "github-actions[bot]")] | length' "$GITHUB_EVENT_PATH")
if [ "$count" -eq 0 ]; then
echo 'No human commits in this push (bot bump, branch delete, or force push); skipping.'
exit 0
fi
jq -n --arg icon "$ICON" --slurpfile e "$GITHUB_EVENT_PATH" '
$e[0] as $ev
| ($ev.commits | map(select(.author.name != "github-actions[bot]"))) as $human
| ($ev.ref | sub("^refs/heads/"; "")) as $branch
| ($human | length) as $total
| ($human[:10] | map(
"[`" + .id[:7] + "`](" + .url + ") "
+ (.message | split("\n")[0] | gsub("—"; "-") | gsub("–"; "-") | .[:120])
+ " - " + .author.name
)) as $lines
| (if $total > 10
then $lines + ["... and " + (($total - 10) | tostring) + " more"]
else $lines
end) as $lines
| {
username: "Aetherphone",
avatar_url: $icon,
embeds: [{
author: { name: "Aetherphone", url: $ev.repository.html_url, icon_url: $icon },
title: ((if $total == 1 then "1 new commit" else (($total | tostring) + " new commits") end) + " on " + $branch),
url: (if $total == 1 then ($human[0].url) else $ev.compare end),
description: ($lines | join("\n")),
color: 5814783,
footer: { text: "Aetherphone", icon_url: $icon },
timestamp: ($human | last | .timestamp)
}]
}
' > payload.json
curl -fsS -H 'Content-Type: application/json; charset=utf-8' -d @payload.json "$WEBHOOK_URL" > /dev/null
echo "Announced $count commit(s) to Discord."