From f08816760ee4e0507bba492d0eb16874e833d721 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Tue, 29 Oct 2024 15:54:53 +0100 Subject: [PATCH 1/3] Update add-tags.yml --- .github/workflows/add-tags.yml | 50 ++++++++++++++-------------------- 1 file changed, 20 insertions(+), 30 deletions(-) diff --git a/.github/workflows/add-tags.yml b/.github/workflows/add-tags.yml index d726fda..f973508 100644 --- a/.github/workflows/add-tags.yml +++ b/.github/workflows/add-tags.yml @@ -14,36 +14,26 @@ jobs: - uses: actions/checkout@v3 - name: update tags run: | - jq -s 'flatten' tokens/*.json > merged.json; - - curl -X 'POST' \ - ${{ secrets.URL_1 }} \ - -H 'accept: application/json' \ - -H 'Content-Type: multipart/form-data' \ - -F 'file=@merged.json;type=application/json' - - curl -X 'POST' \ - ${{ secrets.URL_2 }} \ - -H 'accept: application/json' \ - -H 'Content-Type: multipart/form-data' \ - -F 'file=@merged.json;type=application/json' - - rm merged.json; + declare -A directories_and_urls=( + ["tokens"]="URL_1 URL_2" + ["accounts"]="URL_3 URL_4" + ) - jq -s 'flatten' accounts/*.json > merged.json; - - curl -X 'POST' \ - ${{ secrets.URL_3 }} \ - -H 'accept: application/json' \ - -H 'Content-Type: multipart/form-data' \ - -F 'file=@merged.json;type=application/json' - - curl -X 'POST' \ - ${{ secrets.URL_4 }} \ - -H 'accept: application/json' \ - -H 'Content-Type: multipart/form-data' \ - -F 'file=@merged.json;type=application/json' - - rm merged.json; + # Loop over each directory and its corresponding URLs + for dir in "${!directories_and_urls[@]}"; do + # Merge JSON files in the directory + jq -s 'flatten' "$dir"/*.json > merged.json + + # Iterate over URLs and upload the merged file + for url_key in ${directories_and_urls[$dir]}; do + curl -X 'POST' \ + "${{ secrets[$url_key] }}" \ + -H 'accept: application/json' \ + -H 'Content-Type: multipart/form-data' \ + -F 'file=@merged.json;type=application/json' + done + # Remove the merged file after processing + rm merged.json + done From ca750ec4ba3f8e06f7a4197b2a508517ad1003e2 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Tue, 29 Oct 2024 15:58:00 +0100 Subject: [PATCH 2/3] Update add-tags.yml --- .github/workflows/add-tags.yml | 64 ++++++++++++++++++++++------------ 1 file changed, 42 insertions(+), 22 deletions(-) diff --git a/.github/workflows/add-tags.yml b/.github/workflows/add-tags.yml index f973508..8ee7eca 100644 --- a/.github/workflows/add-tags.yml +++ b/.github/workflows/add-tags.yml @@ -14,26 +14,46 @@ jobs: - uses: actions/checkout@v3 - name: update tags run: | - declare -A directories_and_urls=( - ["tokens"]="URL_1 URL_2" - ["accounts"]="URL_3 URL_4" - ) - - # Loop over each directory and its corresponding URLs - for dir in "${!directories_and_urls[@]}"; do - # Merge JSON files in the directory - jq -s 'flatten' "$dir"/*.json > merged.json - - # Iterate over URLs and upload the merged file - for url_key in ${directories_and_urls[$dir]}; do - curl -X 'POST' \ - "${{ secrets[$url_key] }}" \ - -H 'accept: application/json' \ - -H 'Content-Type: multipart/form-data' \ - -F 'file=@merged.json;type=application/json' - done - - # Remove the merged file after processing - rm merged.json - done + # Define directories and their corresponding URLs explicitly + declare -A directories_and_urls=( + ["tokens"]="URL_1 URL_2" + ["accounts"]="URL_3 URL_4" + ) + + # Loop over each directory and its corresponding URLs + for dir in "${!directories_and_urls[@]}"; do + # Merge JSON files in the directory + jq -s 'flatten' "$dir"/*.json > merged.json + + # Check directory and upload merged file to the specific URLs + if [[ "$dir" == "tokens" ]]; then + curl -X 'POST' \ + "${{ secrets.URL_1 }}" \ + -H 'accept: application/json' \ + -H 'Content-Type: multipart/form-data' \ + -F 'file=@merged.json;type=application/json' + + curl -X 'POST' \ + "${{ secrets.URL_2 }}" \ + -H 'accept: application/json' \ + -H 'Content-Type: multipart/form-data' \ + -F 'file=@merged.json;type=application/json' + elif [[ "$dir" == "accounts" ]]; then + curl -X 'POST' \ + "${{ secrets.URL_3 }}" \ + -H 'accept: application/json' \ + -H 'Content-Type: multipart/form-data' \ + -F 'file=@merged.json;type=application/json' + + curl -X 'POST' \ + "${{ secrets.URL_4 }}" \ + -H 'accept: application/json' \ + -H 'Content-Type: multipart/form-data' \ + -F 'file=@merged.json;type=application/json' + fi + + # Remove the merged file after processing + rm merged.json + done + From 0869481bb48467d9a7598bfc12aa81d2508321b6 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Tue, 29 Oct 2024 16:07:19 +0100 Subject: [PATCH 3/3] Update add-tags.yml --- .github/workflows/add-tags.yml | 62 ++++++++++++++++------------------ 1 file changed, 30 insertions(+), 32 deletions(-) diff --git a/.github/workflows/add-tags.yml b/.github/workflows/add-tags.yml index 8ee7eca..57ee7a2 100644 --- a/.github/workflows/add-tags.yml +++ b/.github/workflows/add-tags.yml @@ -22,38 +22,36 @@ jobs: # Loop over each directory and its corresponding URLs for dir in "${!directories_and_urls[@]}"; do - # Merge JSON files in the directory - jq -s 'flatten' "$dir"/*.json > merged.json - - # Check directory and upload merged file to the specific URLs - if [[ "$dir" == "tokens" ]]; then - curl -X 'POST' \ - "${{ secrets.URL_1 }}" \ - -H 'accept: application/json' \ - -H 'Content-Type: multipart/form-data' \ - -F 'file=@merged.json;type=application/json' - - curl -X 'POST' \ - "${{ secrets.URL_2 }}" \ - -H 'accept: application/json' \ - -H 'Content-Type: multipart/form-data' \ - -F 'file=@merged.json;type=application/json' - elif [[ "$dir" == "accounts" ]]; then - curl -X 'POST' \ - "${{ secrets.URL_3 }}" \ - -H 'accept: application/json' \ - -H 'Content-Type: multipart/form-data' \ - -F 'file=@merged.json;type=application/json' - - curl -X 'POST' \ - "${{ secrets.URL_4 }}" \ - -H 'accept: application/json' \ - -H 'Content-Type: multipart/form-data' \ - -F 'file=@merged.json;type=application/json' - fi - - # Remove the merged file after processing - rm merged.json + # Iterate over each JSON file in the directory + for file in "$dir"/*.json; do + # Check directory and upload each file to the specific URLs + if [[ "$dir" == "tokens" ]]; then + curl -X 'POST' \ + "${{ secrets.URL_1 }}" \ + -H 'accept: application/json' \ + -H 'Content-Type: multipart/form-data' \ + -F "file=@${file};type=application/json" + + curl -X 'POST' \ + "${{ secrets.URL_2 }}" \ + -H 'accept: application/json' \ + -H 'Content-Type: multipart/form-data' \ + -F "file=@${file};type=application/json" + elif [[ "$dir" == "accounts" ]]; then + curl -X 'POST' \ + "${{ secrets.URL_3 }}" \ + -H 'accept: application/json' \ + -H 'Content-Type: multipart/form-data' \ + -F "file=@${file};type=application/json" + + curl -X 'POST' \ + "${{ secrets.URL_4 }}" \ + -H 'accept: application/json' \ + -H 'Content-Type: multipart/form-data' \ + -F "file=@${file};type=application/json" + fi + done done +