76 lines
2.5 KiB
YAML
76 lines
2.5 KiB
YAML
# Forge-Auto-Announce
|
|
# Triggers on tag push (v*). Reads .gitea/forge-posts/v<X.Y.Z>.md from the
|
|
# *tagged tree* (not main), assembles a Discord embed, posts via webhook.
|
|
#
|
|
# Required repo secret: FORGE_DISCORD_WEBHOOK_URL
|
|
# Optional repo secret: FORGE_DISCORD_THREAD_ID (post into a forum thread)
|
|
#
|
|
# Char-cap reminder: Discord embed total (title + description + footer +
|
|
# field values combined) ~5500. Keep .gitea/forge-posts/v*.md trim.
|
|
|
|
name: Forge Auto-Announce
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- 'v*'
|
|
|
|
jobs:
|
|
announce:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout tagged tree
|
|
uses: actions/checkout@v4
|
|
with:
|
|
ref: ${{ github.ref }}
|
|
|
|
- name: Compose embed
|
|
id: embed
|
|
env:
|
|
TAG: ${{ github.ref_name }}
|
|
run: |
|
|
POST_FILE=".gitea/forge-posts/${TAG}.md"
|
|
if [ ! -f "$POST_FILE" ]; then
|
|
echo "No forge-post file for ${TAG} (looked at ${POST_FILE}). Skipping."
|
|
echo "skip=true" >> "$GITHUB_OUTPUT"
|
|
exit 0
|
|
fi
|
|
|
|
TITLE=$(awk -F': ' '/^title:/ {print $2; exit}' "$POST_FILE" | sed 's/^"//;s/"$//')
|
|
SUBTITLE=$(awk -F': ' '/^subtitle:/ {print $2; exit}' "$POST_FILE" | sed 's/^"//;s/"$//')
|
|
BODY=$(awk '/^---$/{c++;next} c==2' "$POST_FILE")
|
|
|
|
jq -n \
|
|
--arg title "${TITLE:-Release ${TAG}}" \
|
|
--arg subtitle "${SUBTITLE}" \
|
|
--arg body "$BODY" \
|
|
--arg tag "$TAG" \
|
|
--arg repo "${{ github.repository }}" \
|
|
'{
|
|
embeds: [{
|
|
title: $title,
|
|
description: ($subtitle + "\n\n" + $body),
|
|
color: 12731404,
|
|
url: ("https://gitea.hellion-forge.cloud/" + $repo + "/releases/tag/" + $tag),
|
|
footer: { text: ($repo + " — " + $tag) }
|
|
}]
|
|
}' > payload.json
|
|
|
|
echo "skip=false" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Post to Discord
|
|
if: steps.embed.outputs.skip != 'true'
|
|
env:
|
|
WEBHOOK: ${{ secrets.FORGE_DISCORD_WEBHOOK_URL }}
|
|
THREAD_ID: ${{ secrets.FORGE_DISCORD_THREAD_ID }}
|
|
run: |
|
|
if [ -z "$WEBHOOK" ]; then
|
|
echo "::error::FORGE_DISCORD_WEBHOOK_URL secret missing"
|
|
exit 1
|
|
fi
|
|
URL="$WEBHOOK"
|
|
if [ -n "$THREAD_ID" ]; then
|
|
URL="${URL}?thread_id=${THREAD_ID}"
|
|
fi
|
|
curl -fsS -X POST -H 'Content-Type: application/json' --data @payload.json "$URL"
|