-
Notifications
You must be signed in to change notification settings - Fork 0
98 lines (93 loc) · 3.87 KB
/
ci_project.yml
File metadata and controls
98 lines (93 loc) · 3.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#Integrate with social network to notify of changes and advance on the websites
name: Social networks notifications
on:
workflow_call:
inputs:
# Required input to receive the status from the calling workflow (e.g., success() or failure())
status:
description: "The final status of the calling job/workflow (success or failure)."
required: true
type: string
# Required input for the latest commit message
commit_message:
description: "The commit message related to the current build."
required: true
type: string
# Required input for the full URL to the calling workflow run
run_url:
description: "The URL to the completed workflow run for logs."
required: true
type: string
# Contextual information for better messages
repo_name:
description: "The repository name."
required: true
type: string
branch:
description: "The branch name."
required: true
type: string
secrets:
DISCORD_WEBHOOK:
required: true
TELEGRAM_TOKEN:
required: true
TELEGRAM_TO:
required: true
jobs:
live_notifications:
runs-on: ubuntu-latest
steps:
- name: Compose notification copy
id: message
shell: bash
run: |
COMMIT_TITLE="$(printf '%s' "${{ inputs.commit_message }}" | head -n 1)"
if [ "${{ inputs.status }}" = "success" ]; then
STATUS_ICON="✅"
STATUS_LABEL="Deployment finished successfully"
STATUS_BODY="The latest website changes are now live."
CTA_LABEL="Open workflow logs"
else
STATUS_ICON="❌"
STATUS_LABEL="Deployment needs attention"
STATUS_BODY="The pipeline stopped before completing. Please review the workflow logs."
CTA_LABEL="Review workflow logs"
fi
{
echo "discord_message<<EOF"
echo "${STATUS_ICON} **${STATUS_LABEL}**"
echo
echo "${STATUS_BODY}"
echo
echo "**Repository:** \`${{ inputs.repo_name }}\`"
echo "**Branch:** \`${{ inputs.branch }}\`"
echo "**Commit:** ${COMMIT_TITLE}"
echo
echo "[${CTA_LABEL}](${{ inputs.run_url }})"
echo "EOF"
echo "telegram_message<<EOF"
echo "${STATUS_ICON} *${STATUS_LABEL}*"
echo
echo "${STATUS_BODY}"
echo
echo "*Repository:* \`${{ inputs.repo_name }}\`"
echo "*Branch:* \`${{ inputs.branch }}\`"
echo "*Commit:* ${COMMIT_TITLE}"
echo
echo "[${CTA_LABEL}](${{ inputs.run_url }})"
echo "EOF"
} >> "$GITHUB_OUTPUT"
- name: Notify Discord
uses: Ilshidur/action-discord@master
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
with:
args: ${{ steps.message.outputs.discord_message }}
- name: Notify Telegram
uses: appleboy/telegram-action@master
with:
to: ${{ secrets.TELEGRAM_TO }}
token: ${{ secrets.TELEGRAM_TOKEN }}
format: markdown
message: ${{ steps.message.outputs.telegram_message }}