-
-
Notifications
You must be signed in to change notification settings - Fork 119
140 lines (127 loc) · 5.81 KB
/
discord.yml
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
130
131
132
133
134
135
136
137
138
139
140
name: Upload to Discord
on:
workflow_call:
inputs:
commit_log:
required: true
type: string
version:
required: true
type: string
jobs:
upload:
runs-on: ubuntu-latest
steps:
- name: Upload APK to Discord
shell: bash
run: |
# Author information map (replace with your own values)
declare -A author_map=(
["ibo"]="951737931159187457|takarealist112"
["aayush262"]="918825160654598224|aayush262"
)
function get_author_info() {
local commits=$1
local author_info=()
while read -r line; do
if [[ $line =~ ^●\ .* ~(.*)$ ]]; then
author=${BASH_REMATCH[1]}
author_name=$(echo "$author" | cut -d'<' -f1 | xargs)
author_login=$(echo "$author" | cut -d'<' -f2 | cut -d'>' -f1 | xargs)
# Check if author information is provided
if [[ -n "${author_map[$author_name]}" ]]; then
author_info+=("$author_name|$author_login|${author_map[$author_name]}")
else
author_info+=("$author_name|$author_login")
fi
fi
done <<< "$commits"
if [ "${#authors[@]}" -gt 0 ]; then
echo "Missing information for the following authors: ${authors[*]}"
echo "Please provide their Discord IDs and AniList usernames in the author_map variable."
return 1
fi
if [ "${#author_info[@]}" -eq 1 ]; then
IFS='|' read -ra author_data <<< "${author_info[0]}"
author_name=${author_data[0]}
author_login=${author_data[1]}
if [ "${#author_data[@]}" -eq 3 ]; then
discord_id=${author_data[2]%|*}
anilist_username=${author_data[2]#*|}
thumbnail_url="https://avatars.githubusercontent.com/u/$author_login"
developer_field="◗ **$author_name**\n- Discord: <@$discord_id>\n- Github: [$author_name](<https://github.com/$author_login>)\n- Anilist: [$anilist_username](<https://anilist.co/user/$anilist_username>)"
else
thumbnail_url="https://avatars.githubusercontent.com/u/$author_login"
developer_field="◗ **$author_name**\n- Github: [$author_name](<https://github.com/$author_login>)"
fi
else
thumbnail_url="https://i.imgur.com/5o3Y9Jb.gif"
developer_field=""
for author_data in "${author_info[@]}"; do
IFS='|' read -ra author_data <<< "$author_data"
author_name=${author_data[0]}
author_login=${author_data[1]}
if [ "${#author_data[@]}" -eq 3 ]; then
discord_id=${author_data[2]%|*}
anilist_username=${author_data[2]#*|}
developer_field+="◗ **$author_name**\n- Discord: <@$discord_id>\n- Github: [$author_name](<https://github.com/$author_login>)\n- Anilist: [$anilist_username](<https://anilist.co/user/$anilist_username>)\n"
else
developer_field+="◗ **$author_name**\n- Github: [$author_name](<https://github.com/$author_login>)\n"
fi
done
fi
echo "$thumbnail_url"
echo "$developer_field"
}
commit_messages=$(echo "${{ inputs.commit_log }}" | sed 's/%0A/\n/g; s/^/\n/')
max_length=1000
if [ ${#commit_messages} -gt $max_length ]; then
commit_messages="${commit_messages:0:$max_length}... (truncated)"
fi
read -r thumbnail_url developer_field < <(get_author_info "$commit_messages")
if [ $? -ne 0 ]; then
exit 1
fi
discord_data=$(jq -nc \
--arg field_value "$commit_messages" \
--arg footer_text "Version ${{ inputs.version }}" \
--arg timestamp "$(date -u +%Y-%m-%dT%H:%M:%S.000Z)" \
--arg thumbnail_url "$thumbnail_url" \
--arg developer_field "$developer_field" \
'{
"content": null,
"embeds": [
{
"title": "New Alpha-Build dropped",
"description": "<@&1225347048321191996>",
"color": 15532323,
"fields": [
{
"name": "Commits:",
"value": $field_value,
"inline": true
},
{
"name": "Developers:",
"value": $developer_field,
"inline": true
}
],
"footer": {
"text": $footer_text
},
"timestamp": $timestamp,
"thumbnail": {
"url": $thumbnail_url
}
}
],
"attachments": []
}')
echo "$discord_data"
curl -H "Content-Type: application/json" \
-d "$discord_data" \
${{ secrets.DISCORD_WEBHOOK }}
echo "$response_headers"
curl -F "dantotsu_debug=@app/build/outputs/apk/google/alpha/app-google-alpha.apk" \
${{ secrets.DISCORD_WEBHOOK }}