-
Notifications
You must be signed in to change notification settings - Fork 93
81 lines (68 loc) · 3.02 KB
/
sync.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
name: Sync settings
on:
push:
branches:
- 'main'
jobs:
upload_settings:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install jq
run: sudo apt-get install -y jq
- name: Process and Upload Settings
id: process_and_upload
env:
AUTHORIZATION: ${{ secrets.AUTHORIZATION }}
REPO_URL: ${{ github.repository }}
COMMIT_HASH: ${{ github.sha }}
run: |
set -e
settings="[]"
process_directory() {
local branch="$1"
echo "Processing settings for branch: $branch"
for file in "LiquidBounce/settings/$branch"/*; do
if [ -f "$file" ]; then
setting_id=$(basename "$file" | cut -f 1 -d '.')
raw_url="https://raw.githubusercontent.com/${REPO_URL}/${COMMIT_HASH}/${file}"
checksum=$(sha256sum "$file" | cut -d ' ' -f 1)
timestamp=$(git log -1 --format=%ai -- "$file" | cut -d ' ' -f 1,2 | tr ' ' 'T')Z
contributors=$(git log -1 --format='%an <%ae>' -- "$file")
settings=$(echo "$settings" | jq --arg name "$setting_id" \
--arg branch "$branch" \
--arg url "$raw_url" \
--arg checksum "$checksum" \
--arg timestamp "$timestamp" \
--arg contributors "$contributors" \
'. += [{
"name": $name,
"branch": $branch,
"url": $url,
"checksum": $checksum,
"timestamp": $timestamp,
"contributors": $contributors
}]')
fi
done
}
for branch in legacy nextgen; do
process_directory "$branch"
done
echo "$settings" > settings.json
echo "Uploading settings..."
curl --fail -X POST \
-H "Authorization: $AUTHORIZATION" \
-H "Content-Type: application/json" \
-d @"settings.json" \
"https://api.liquidbounce.net/api/v3/marketplace/sync" \
&& echo "Settings successfully uploaded" \
|| (echo "Failed to upload settings" && exit 1)
- name: Upload JSON Files to Artifacts
uses: actions/upload-artifact@v4
with:
name: settings
path: 'settings.json'