Update cubecraft.json #682
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Sync settings | |
on: | |
push: | |
branches: | |
- '*' | |
jobs: | |
upload_settings: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 # Fetch all history for all tags and branches | |
- name: Create TAR and Meta Files | |
id: create_tar | |
run: | | |
for branch_folder in LiquidBounce/settings/*; do | |
if [ -d "$branch_folder" ]; then | |
echo "Processing files in directory: $branch_folder" | |
branch_name=$(basename "$branch_folder") | |
# Create a TAR file with the settings content | |
tar -cvf "$branch_name.tar" -C "$branch_folder" . | |
for file in "$branch_folder"/*; do | |
if [ -f "$file" ]; then | |
setting_id=$(basename "$file" | cut -f 1 -d '.') | |
contributors=$(git log --follow --format="%aN" -- "$file" | sort | uniq | paste -sd "," -) | |
meta_file="$setting_id.meta" | |
modify_date=$(git log -1 --format=%ai -- "$file" | cut -d ' ' -f 1,2 | tr ' ' 'T')Z | |
echo "{\"setting_id\":\"$setting_id\",\"contributors\":\"$contributors\",\"timestamp\":\"$modify_date\"}" > "$meta_file" | |
# Append the .meta file to the TAR archive if it exists | |
if [ -f "$meta_file" ]; then | |
tar -rvf "$branch_name.tar" "$meta_file" | |
# Clean up the .meta file after adding it to the archive | |
rm "$meta_file" | |
fi | |
fi | |
done | |
fi | |
done | |
- name: Upload TAR and Meta Files | |
id: upload_files | |
env: | |
AUTHORIZATION: ${{ secrets.AUTHORIZATION }} | |
run: | | |
for branch_folder in LiquidBounce/settings/*; do | |
if [ -d "$branch_folder" ]; then | |
branch_name=$(basename "$branch_folder") | |
echo "Uploading tar file: $branch_name.tar" | |
curl -X POST -H "Authorization: $AUTHORIZATION" -F "settings_bundle=@$branch_name.tar" "https://api.liquidbounce.net/api/v1/client/$branch_name/settings/upload/bundle" | |
fi | |
done | |
- name: Upload TAR Files to Artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: tar-artifacts | |
path: ./*.tar |