forked from cloudwego/eino-ext
-
Notifications
You must be signed in to change notification settings - Fork 0
129 lines (119 loc) · 4.2 KB
/
tag-notification.yml
File metadata and controls
129 lines (119 loc) · 4.2 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
name: Tag Notification
on:
push:
tags:
- '**/v*'
jobs:
notify:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Fetch tag info
run: |
git fetch --tags -f
- name: Get tag info and send notification
run: |
# Get the tag name
TAG_NAME="${{ github.ref_name }}"
echo "Processing tag: $TAG_NAME"
# Extract version (last part after v)
VERSION=$(echo "$TAG_NAME" | grep -o '[^/]*$')
# Extract module path (everything before the version)
MODULE_PATH=$(echo "$TAG_NAME" | sed "s|/$VERSION$||")
# Get tag message
echo "Getting tag message..."
TAG_MESSAGE=$(git tag -l --format='%(contents)' "$TAG_NAME")
echo "Tag message:"
echo "$TAG_MESSAGE"
echo "---"
# Create base content parts
HEADER="### New Tag Created: \`$TAG_NAME\`"
MODULE_INFO="Module Path: \`$MODULE_PATH\`"
VERSION_INFO="Version: \`$VERSION\`"
# Prepare the message parts for jq
if [ ! -z "$TAG_MESSAGE" ]; then
# Pass all parts to jq and let it handle the formatting
jq -n \
--arg header "$HEADER" \
--arg module "$MODULE_INFO" \
--arg version "$VERSION_INFO" \
--arg notes "$TAG_MESSAGE" \
--arg repo_url "https://github.com/${{ github.repository }}/releases/tag/$TAG_NAME" \
'{
"msg_type": "interactive",
"card": {
"elements": [
{
"tag": "markdown",
"content": ($header + "\n\n" + $module + "\n" + $version + "\n\n### Release Notes:\n" + $notes)
},
{
"tag": "action",
"actions": [
{
"tag": "button",
"text": {
"tag": "plain_text",
"content": "🔗 View Tag"
},
"url": $repo_url,
"type": "default"
}
]
}
],
"header": {
"title": {
"tag": "plain_text",
"content": "New Tag Created"
}
}
}
}' > webhook_payload.json
else
# Without release notes
jq -n \
--arg header "$HEADER" \
--arg module "$MODULE_INFO" \
--arg version "$VERSION_INFO" \
--arg repo_url "https://github.com/${{ github.repository }}/releases/tag/$TAG_NAME" \
'{
"msg_type": "interactive",
"card": {
"elements": [
{
"tag": "markdown",
"content": ($header + "\n\n" + $module + "\n" + $version)
},
{
"tag": "action",
"actions": [
{
"tag": "button",
"text": {
"tag": "plain_text",
"content": "🔗 View Tag"
},
"url": $repo_url,
"type": "default"
}
]
}
],
"header": {
"title": {
"tag": "plain_text",
"content": "New Tag Created"
}
}
}
}' > webhook_payload.json
fi
# Send webhook
curl -X POST \
-H "Content-Type: application/json" \
-d @webhook_payload.json \
"${{ secrets.FEISHU_WEBHOOK_URL }}"