Skip to content

add core hub

add core hub #457

name: Upload Changed Networks
on:
push:
branches:
- main
jobs:
upload_changed_networks:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2
with:
fetch-depth: 0
ref: main
- name: Upload changed jsons
id: upload_changed_jsons
env:
SAVE_NETWORK_API_KEY: ${{ secrets.SAVE_NETWORK_API_KEY }}
run: |
# Use git to get the list of changed files
changed_files=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }})
# Initialize an empty array to store the changed network jsons
changed_jsons=()
# Loop through the changed files to fetch the content
for file in $changed_files; do
# Use the file command to check the MIME type
mime_type=$(file -b --mime-type "$file")
# Check if the MIME type is JSON
if [[ ! "$mime_type" == "application/json" ]]; then
continue
fi
# Read the content of the file
file_content=$(cat "$file")
# Parse the JSON data
parsed_json=$(echo "$file_content" | jq -c .)
# Fetch rollapp env
env=$(echo $file | cut -d'/' -f1)
case $env in
"core")
save_network_api="https://savenetworkrequest-zbrmx4rjia-uc.a.run.app"
;;
"devnet")
save_network_api="https://savenetworkrequest-lmw4daeqdq-uc.a.run.app"
;;
"testnet")
save_network_api="https://savenetworkrequest-p7gld3dazq-uc.a.run.app"
;;
"mainnet")
save_network_api="https://savenetworkrequest-xqbg2swtrq-uc.a.run.app"
;;
*)
esac
# Make an API post request with the extracted json
curl -X POST \
-H "Content-type: application/json" \
-H "Authorization: Bearer $SAVE_NETWORK_API_KEY" \
-d "$parsed_json" \
$save_network_api
done