mirror of
https://github.com/Matysh/houseplan-card
synced 2026-09-29 03:09:36 +00:00
96 lines
3.3 KiB
YAML
96 lines
3.3 KiB
YAML
name: Announce release
|
|
# Telegram notifications for t.me/ha_houseplan (owner request, 2026-08-07).
|
|
# Stable releases are announced; prereleases are deliberately silent.
|
|
# workflow_dispatch exists purely as a connectivity test button and therefore
|
|
# remains allowed to send a test message.
|
|
on:
|
|
release:
|
|
types: [published]
|
|
workflow_dispatch: {}
|
|
workflow_call:
|
|
inputs:
|
|
reusable:
|
|
required: true
|
|
type: boolean
|
|
tag:
|
|
required: true
|
|
type: string
|
|
release_name:
|
|
required: true
|
|
type: string
|
|
url:
|
|
required: true
|
|
type: string
|
|
prerelease:
|
|
required: true
|
|
type: boolean
|
|
ref:
|
|
required: true
|
|
type: string
|
|
secrets:
|
|
TELEGRAM_BOT_TOKEN:
|
|
required: true
|
|
TELEGRAM_CHAT_ID:
|
|
required: true
|
|
permissions:
|
|
contents: read
|
|
jobs:
|
|
telegram:
|
|
if: ${{ github.event_name == 'workflow_dispatch' || (github.event_name == 'release' && github.event.release.prerelease == false) || (github.event_name == 'workflow_call' && inputs.prerelease == false) }}
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Check out release notes for a reusable call
|
|
if: ${{ inputs.reusable == true }}
|
|
uses: actions/checkout@v7
|
|
with:
|
|
ref: ${{ inputs.ref }}
|
|
- name: Send to Telegram
|
|
env:
|
|
TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
|
|
CHAT: ${{ secrets.TELEGRAM_CHAT_ID }}
|
|
CALLED: ${{ inputs.reusable }}
|
|
INPUT_TAG: ${{ inputs.tag }}
|
|
INPUT_NAME: ${{ inputs.release_name }}
|
|
INPUT_URL: ${{ inputs.url }}
|
|
INPUT_PRE: ${{ inputs.prerelease }}
|
|
RELEASE_TAG: ${{ github.event.release.tag_name }}
|
|
RELEASE_NAME: ${{ github.event.release.name }}
|
|
RELEASE_URL: ${{ github.event.release.html_url }}
|
|
RELEASE_PRE: ${{ github.event.release.prerelease }}
|
|
# The body goes through env, never through shell interpolation —
|
|
# release notes are arbitrary text.
|
|
RELEASE_BODY: ${{ github.event.release.body }}
|
|
EVENT: ${{ github.event_name }}
|
|
run: |
|
|
set -euo pipefail
|
|
if [ "$EVENT" = "workflow_dispatch" ] && [ "$CALLED" != "true" ]; then
|
|
TEXT="✅ Тест: оповещения о релизах houseplan-card подключены."
|
|
else
|
|
if [ "$CALLED" = "true" ]; then
|
|
TAG=$INPUT_TAG
|
|
NAME=$INPUT_NAME
|
|
URL=$INPUT_URL
|
|
PRE=$INPUT_PRE
|
|
BODY=$(cat docs/RELEASE-NOTES.md)
|
|
else
|
|
TAG=$RELEASE_TAG
|
|
NAME=$RELEASE_NAME
|
|
URL=$RELEASE_URL
|
|
PRE=$RELEASE_PRE
|
|
BODY=$RELEASE_BODY
|
|
fi
|
|
if [ "$PRE" = "true" ]; then
|
|
echo "Prerelease Telegram announcement is disabled"
|
|
exit 0
|
|
fi
|
|
KIND="🏠 Релиз"
|
|
SUMMARY=$(printf '%s' "$BODY" | head -c 2500)
|
|
TEXT=$(printf '%s houseplan-card %s — %s\n\n%s\n\n%s' \
|
|
"$KIND" "$TAG" "$NAME" "$SUMMARY" "$URL")
|
|
fi
|
|
curl -sS --fail-with-body -X POST \
|
|
"https://api.telegram.org/bot$TOKEN/sendMessage" \
|
|
--data-urlencode "chat_id=$CHAT" \
|
|
--data-urlencode "text=$TEXT" \
|
|
-d disable_web_page_preview=true
|