Skip to content

Notify Telegram on Release #29

Notify Telegram on Release

Notify Telegram on Release #29

Workflow file for this run

name: Notify Telegram on Release
on:
release:
types: [published]
workflow_dispatch:
jobs:
notify:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Get release info
id: release-info
run: |
echo "RELEASE_TAG=${{ github.event.release.tag_name }}" >> $GITHUB_ENV
echo "RELEASE_NAME=${{ github.event.release.name }}" >> $GITHUB_ENV
echo "RELEASE_BODY=${{ github.event.release.body }}" >> $GITHUB_ENV
- name: Get current time
id: current_time
run: echo "CURRENT_TIME=$(TZ=Asia/Jakarta date +'%Y-%m-%d %H:%M:%S')" >> $GITHUB_ENV
- name: Notify Telegram
env:
TELEGRAM_TOKEN: ${{ secrets.TELEGRAM_TOKEN }}
CHAT_ID: ${{ secrets.CHAT_ID }}
RELEASE_TAG: ${{ env.RELEASE_TAG }}
RELEASE_NAME: ${{ env.RELEASE_NAME }}
RELEASE_BODY: ${{ env.RELEASE_BODY }}
CURRENT_TIME: ${{ env.CURRENT_TIME }}
REPLY_TO_MESSAGE_ID: ${{ secrets.REPLY_TO_MESSAGE_ID }}
run: |
MESSAGE=$(cat <<-EOF
▬▬▬▬▬▬▬▬▬▬▬▬▬▬
NEW UPDATE
▬▬▬▬▬▬▬▬▬▬▬▬▬▬
NAME : \`${RELEASE_NAME}\`
TAG : \`${RELEASE_TAG}\`
DESC : \`${RELEASE_BODY}\`
DATE : \`${CURRENT_TIME}\`
REPO : \`Maizil41/RadiusMonitor\`
URL : [Click Here](https://github.com/Maizil41/RadiusMonitor/releases/tag/${RELEASE_TAG})
▬▬▬▬▬▬▬▬▬▬▬▬▬▬
EOF
)
curl -s -X POST "https://api.telegram.org/bot$TELEGRAM_TOKEN/sendMessage" \
-d chat_id=$CHAT_ID \
-d parse_mode=Markdown \
-d text="$MESSAGE" \
-d reply_to_message_id=$REPLY_TO_MESSAGE_ID