-
-
Notifications
You must be signed in to change notification settings - Fork 84
65 lines (57 loc) · 2.03 KB
/
webhook_translate.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
name: translate update
on:
push:
branches:
- master
paths:
- src/main/resources/assets/skyblocker/lang/en_us.json
jobs:
webhook:
if: github.repository_owner == 'SkyblockerMod'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.20'
- uses: actions/cache@v4
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-pkg-mod-${{ hashFiles('go.sum') }}
- name: Install jd
run: go install github.com/josephburnett/jd@latest
- name: Translate notification
shell: bash
run: |
OUTPUT=$(go run github.com/josephburnett/jd@latest <(git show HEAD^:src/main/resources/assets/skyblocker/lang/en_us.json) <(git show HEAD:src/main/resources/assets/skyblocker/lang/en_us.json) || true)
OUTPUT=$(echo "$OUTPUT" | sed 's/"/\\"/g')
OUTPUT=$(echo "$OUTPUT" | sed 's/\\n/\\\\n/g')
OUTPUT="\`\`\`diff
$OUTPUT
\`\`\`"
OUTPUT=$(jq -Rn --arg str "$OUTPUT" '$str' | sed -E "s|^(['\"])(.*)\1$|\2|g")
JSON_PAYLOAD='{
"content": "<@&1134566053138145330>",
"embeds": [
{
"title": "Something Changed (Click me)",
"description": "'"${OUTPUT}"'",
"url": "https://translate.hysky.de/projects/Skyblocker/skyblocker",
"color": 5808639,
"image": {
"url": "https://translate.hysky.de/widgets/Skyblocker/-/skyblocker/88x31-grey.png?uuid='$(uuidgen)'"
}
}
],
"attachments": []
}'
if echo "$JSON_PAYLOAD" | jq . &>/dev/null; then
curl -H "Content-Type: application/json" --data-binary "$JSON_PAYLOAD" "${{ secrets.DISCORD_TRANSLATE_WEBHOOK }}"
else
echo "Error:"
echo "$JSON_PAYLOAD"
fi