ci: Telegram notify on prod deploy + dev→Gitea sync (success/fail with commit info)
Some checks failed
Sync dev → Gitea / Mirror dev to Gitea (push) Has been cancelled
Some checks failed
Sync dev → Gitea / Mirror dev to Gitea (push) Has been cancelled
This commit is contained in:
35
.github/workflows/deploy.yml
vendored
35
.github/workflows/deploy.yml
vendored
@@ -79,3 +79,38 @@ jobs:
|
||||
-H "Authorization: Bearer ${{ secrets.FUSION_DAEMON_TOKEN }}" \
|
||||
"https://fusion.semih.ai/api/routines/${{ secrets.FUSION_CHANGELOG_AUTOMATION_ID }}/trigger?projectId=proj_155fecc31ef14928&scope=project" \
|
||||
|| echo "Fusion trigger failed (non-fatal, continuing)"
|
||||
|
||||
- name: Notify Telegram
|
||||
if: always()
|
||||
continue-on-error: true
|
||||
env:
|
||||
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
|
||||
TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }}
|
||||
JOB_STATUS: ${{ job.status }}
|
||||
COMMIT_SHA: ${{ github.sha }}
|
||||
COMMIT_MSG: ${{ github.event.head_commit.message }}
|
||||
COMMIT_AUTHOR: ${{ github.event.head_commit.author.name }}
|
||||
REF_NAME: ${{ github.ref_name }}
|
||||
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
|
||||
run: |
|
||||
if [ -z "${TELEGRAM_BOT_TOKEN:-}" ] || [ -z "${TELEGRAM_CHAT_ID:-}" ]; then
|
||||
echo "Telegram secrets not configured — skipping notification"
|
||||
exit 0
|
||||
fi
|
||||
SHORT_SHA="${COMMIT_SHA:0:7}"
|
||||
FIRST_LINE=$(printf "%s" "$COMMIT_MSG" | head -n1)
|
||||
if [ "$JOB_STATUS" = "success" ]; then
|
||||
ICON="✅"; TITLE="sase.tr — Prod deploy başarılı"
|
||||
else
|
||||
ICON="❌"; TITLE="sase.tr — Prod deploy BAŞARISIZ ($JOB_STATUS)"
|
||||
fi
|
||||
escape() { printf "%s" "$1" | sed 's/&/\&/g; s/</\</g; s/>/\>/g'; }
|
||||
BODY="$ICON <b>$(escape "$TITLE")</b>%0A%0A<b>Branch:</b> <code>$(escape "$REF_NAME")</code>%0A<b>Commit:</b> <code>$SHORT_SHA</code> $(escape "$FIRST_LINE")%0A<b>Author:</b> $(escape "$COMMIT_AUTHOR")%0A%0A<a href=\"$RUN_URL\">Workflow run</a>"
|
||||
curl -sS --max-time 15 \
|
||||
-X POST "https://api.telegram.org/bot${TELEGRAM_BOT_TOKEN}/sendMessage" \
|
||||
-d "chat_id=${TELEGRAM_CHAT_ID}" \
|
||||
-d "parse_mode=HTML" \
|
||||
-d "disable_web_page_preview=true" \
|
||||
--data-urlencode "text=$(printf "%s" "$BODY" | sed 's/%0A/\n/g')" \
|
||||
| head -c 500
|
||||
echo
|
||||
|
||||
36
.github/workflows/sync-dev-to-gitea.yml
vendored
36
.github/workflows/sync-dev-to-gitea.yml
vendored
@@ -38,3 +38,39 @@ jobs:
|
||||
# rather than silently force-overwriting.
|
||||
git push "$GITEA_PUSH_URL" HEAD:refs/heads/dev
|
||||
echo "✓ dev synced to Gitea ($(git rev-parse --short HEAD))"
|
||||
|
||||
- name: Notify Telegram
|
||||
if: always()
|
||||
continue-on-error: true
|
||||
env:
|
||||
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
|
||||
TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }}
|
||||
JOB_STATUS: ${{ job.status }}
|
||||
COMMIT_SHA: ${{ github.sha }}
|
||||
COMMIT_MSG: ${{ github.event.head_commit.message }}
|
||||
COMMIT_AUTHOR: ${{ github.event.head_commit.author.name }}
|
||||
REF_NAME: ${{ github.ref_name }}
|
||||
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
|
||||
run: |
|
||||
if [ -z "${TELEGRAM_BOT_TOKEN:-}" ] || [ -z "${TELEGRAM_CHAT_ID:-}" ]; then
|
||||
echo "Telegram secrets not configured — skipping notification"
|
||||
exit 0
|
||||
fi
|
||||
SHORT_SHA="${COMMIT_SHA:0:7}"
|
||||
FIRST_LINE=$(printf "%s" "$COMMIT_MSG" | head -n1)
|
||||
if [ -z "$FIRST_LINE" ]; then FIRST_LINE="(manual dispatch)"; fi
|
||||
if [ "$JOB_STATUS" = "success" ]; then
|
||||
ICON="✅"; TITLE="dev.sase.tr — Gitea sync başarılı"
|
||||
else
|
||||
ICON="❌"; TITLE="dev.sase.tr — Gitea sync BAŞARISIZ ($JOB_STATUS)"
|
||||
fi
|
||||
escape() { printf "%s" "$1" | sed 's/&/\&/g; s/</\</g; s/>/\>/g'; }
|
||||
BODY="$ICON <b>$(escape "$TITLE")</b>%0A%0A<b>Branch:</b> <code>$(escape "$REF_NAME")</code>%0A<b>Commit:</b> <code>$SHORT_SHA</code> $(escape "$FIRST_LINE")%0A<b>Author:</b> $(escape "$COMMIT_AUTHOR")%0A%0A<a href=\"$RUN_URL\">Workflow run</a>"
|
||||
curl -sS --max-time 15 \
|
||||
-X POST "https://api.telegram.org/bot${TELEGRAM_BOT_TOKEN}/sendMessage" \
|
||||
-d "chat_id=${TELEGRAM_CHAT_ID}" \
|
||||
-d "parse_mode=HTML" \
|
||||
-d "disable_web_page_preview=true" \
|
||||
--data-urlencode "text=$(printf "%s" "$BODY" | sed 's/%0A/\n/g')" \
|
||||
| head -c 500
|
||||
echo
|
||||
|
||||
Reference in New Issue
Block a user