feat: add Telegram notification support and remove explicit ntfy/Gmail inputs
This commit is contained in:
40
action.yml
40
action.yml
@@ -1,39 +1,14 @@
|
|||||||
name: "Deploy Notification"
|
name: "Deploy Notification"
|
||||||
description: "Notify deployment result via ntfy and Gmail SMTP"
|
description: "Notify deployment result via ntfy, Gmail SMTP, and Telegram"
|
||||||
|
|
||||||
inputs:
|
inputs:
|
||||||
status:
|
status:
|
||||||
description: "Deployment status (success | failure)"
|
|
||||||
required: true
|
required: true
|
||||||
|
|
||||||
title:
|
title:
|
||||||
description: "Notification title"
|
|
||||||
required: true
|
required: true
|
||||||
|
|
||||||
message:
|
message:
|
||||||
description: "Notification message"
|
|
||||||
required: true
|
required: true
|
||||||
|
|
||||||
ntfy_url:
|
|
||||||
description: "ntfy server URL (e.g. https://ntfy.example.com)"
|
|
||||||
default: "https://ntfy.hcmc.online"
|
|
||||||
required: false
|
|
||||||
|
|
||||||
ntfy_topic:
|
|
||||||
description: "ntfy topic"
|
|
||||||
default: "deploy"
|
|
||||||
required: false
|
|
||||||
|
|
||||||
gmail_user:
|
|
||||||
description: "Gmail address"
|
|
||||||
default: "sitienbmt@gmail.com"
|
|
||||||
required: false
|
|
||||||
|
|
||||||
gmail_to:
|
|
||||||
description: "Recipient email"
|
|
||||||
default: "sitienbmt@gmail.com"
|
|
||||||
required: false
|
|
||||||
|
|
||||||
runs:
|
runs:
|
||||||
using: "composite"
|
using: "composite"
|
||||||
steps:
|
steps:
|
||||||
@@ -43,10 +18,15 @@ runs:
|
|||||||
STATUS: ${{ inputs.status }}
|
STATUS: ${{ inputs.status }}
|
||||||
TITLE: ${{ inputs.title }}
|
TITLE: ${{ inputs.title }}
|
||||||
MESSAGE: ${{ inputs.message }}
|
MESSAGE: ${{ inputs.message }}
|
||||||
NTFY_URL: ${{ inputs.ntfy_url }}
|
|
||||||
NTFY_TOPIC: ${{ inputs.ntfy_topic }}
|
NTFY_URL: "https://ntfy.hcmc.online"
|
||||||
GMAIL_USER: ${{ inputs.gmail_user }}
|
NTFY_TOPIC: "deploy"
|
||||||
GMAIL_TO: ${{ inputs.gmail_to }}
|
|
||||||
|
GMAIL_USER: "sitienbmt@gmail.com"
|
||||||
|
GMAIL_TO: "sitienbmt@gmail.com"
|
||||||
GMAIL_PASS: ${{ secrets.GMAIL_APP_PASSWORD }}
|
GMAIL_PASS: ${{ secrets.GMAIL_APP_PASSWORD }}
|
||||||
|
|
||||||
|
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
|
||||||
|
TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }}
|
||||||
run: |
|
run: |
|
||||||
bash ${{ github.action_path }}/notify.sh
|
bash ${{ github.action_path }}/notify.sh
|
||||||
|
|||||||
10
notify.sh
10
notify.sh
@@ -6,6 +6,8 @@ if [ "$STATUS" = "failure" ]; then
|
|||||||
ICON="❌"
|
ICON="❌"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
TEXT="$ICON *$TITLE*%0A%0A$MESSAGE"
|
||||||
|
|
||||||
# ---- ntfy ----
|
# ---- ntfy ----
|
||||||
if [ -n "$NTFY_URL" ] && [ -n "$NTFY_TOPIC" ]; then
|
if [ -n "$NTFY_URL" ] && [ -n "$NTFY_TOPIC" ]; then
|
||||||
curl -s -X POST "$NTFY_URL/$NTFY_TOPIC" \
|
curl -s -X POST "$NTFY_URL/$NTFY_TOPIC" \
|
||||||
@@ -26,4 +28,12 @@ if [ -n "$GMAIL_USER" ] && [ -n "$GMAIL_TO" ]; then
|
|||||||
-au"$GMAIL_USER" \
|
-au"$GMAIL_USER" \
|
||||||
-ap"$GMAIL_PASS" \
|
-ap"$GMAIL_PASS" \
|
||||||
"$GMAIL_TO"
|
"$GMAIL_TO"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# ---- Telegram ----
|
||||||
|
if [ -n "$TELEGRAM_BOT_TOKEN" ] && [ -n "$TELEGRAM_CHAT_ID" ]; then
|
||||||
|
curl -s -X POST "https://api.telegram.org/bot${TELEGRAM_BOT_TOKEN}/sendMessage" \
|
||||||
|
-d chat_id="$TELEGRAM_CHAT_ID" \
|
||||||
|
-d parse_mode="Markdown" \
|
||||||
|
-d text="$TEXT"
|
||||||
fi
|
fi
|
||||||
Reference in New Issue
Block a user