diff --git a/.github/scripts/clear-s3-caches.sh b/.github/scripts/clear-s3-caches.sh index 8a665a675..d1844e0b7 100755 --- a/.github/scripts/clear-s3-caches.sh +++ b/.github/scripts/clear-s3-caches.sh @@ -2,6 +2,8 @@ set -e s3_path=$1 +echo "Clearing S3 caches for path: ${s3_path}" + #Flush AWS Cloudfront Cache invalidation_json=`aws cloudfront create-invalidation --distribution-id ECAO9Q8651L8M --output json --paths "/${s3_path}/*"` echo "Invalidation response: ${invalidation_json}" @@ -17,46 +19,46 @@ done echo "Final invalidation status: ${invalidation_status}" # Flush CloudFlare Cache -#s3_url=s3://dist.springsource.com/${s3_path} -#files=`aws s3 cp ${s3_url} . --recursive --include "*" --dryrun` -#counter=0 -#json="" -#NL=$'\n' -#FILES_BATCH=7 -#for file in $files -#do -# if [[ "$counter" -eq 0 ]]; then -# json="{\"files\": [${NL}" -# fi -# if [[ "$file" =~ ^"s3://dist.springsource.com" ]]; then -# echo "Processing ${file}" -# counter=$((counter+1)) -# path=${file:26} -# json="${json}\"http://dist.springsource.com${path}\",${NL}\"https://dist.springsource.com${path}\",${NL}\"http://download.springsource.com${path}\",${NL}\"https://download.springsource.com${path}\",${NL}" -# fi -# if [[ "$counter" -eq "$FILES_BATCH" ]]; then -# json="${json::-2}${NL}]}" -# echo $json -# -# curl -X DELETE "https://api.cloudflare.com/client/v4/zones/${CLOUDFLARE_ZONE_ID}/purge_cache" \ -# -H "X-Auth-Email: spring-sysadmin@pivotal.io" \ -# -H "Authorization: Bearer ${CLOUDFLARE_CACHE_TOKEN}" \ -# -H "Content-Type: application/json" \ -# --data "${json}" -# -# json="" -# counter=0 -# fi -#done -#if ! [[ "$counter" -eq 0 ]]; then -# json="${json::-2}${NL}]}" -# echo $json -# -# curl -X DELETE "https://api.cloudflare.com/client/v4/zones/${CLOUDFLARE_ZONE_ID}/purge_cache" \ -# -H "X-Auth-Email: spring-sysadmin@pivotal.io" \ -# -H "Authorization: Bearer ${CLOUDFLARE_CACHE_TOKEN}" \ -# -H "Content-Type: application/json" \ -# --data "${json}" -#fi +s3_url=s3://dist.springsource.com/${s3_path} +files=`aws s3 cp ${s3_url} . --recursive --include "*" --dryrun` +counter=0 +json="" +NL=$'\n' +FILES_BATCH=7 +for file in $files +do + if [[ "$counter" -eq 0 ]]; then + json="{\"files\": [${NL}" + fi + if [[ "$file" =~ ^"s3://dist.springsource.com" ]]; then + echo "Processing ${file}" + counter=$((counter+1)) + path=${file:26} + json="${json}\"http://dist.springsource.com${path}\",${NL}\"https://dist.springsource.com${path}\",${NL}\"http://download.springsource.com${path}\",${NL}\"https://download.springsource.com${path}\",${NL}" + fi + if [[ "$counter" -eq "$FILES_BATCH" ]]; then + json="${json::-2}${NL}]}" + echo $json + + curl -X DELETE "https://api.cloudflare.com/client/v4/zones/${CLOUDFLARE_ZONE_ID}/purge_cache" \ + -H "X-Auth-Email: spring-sysadmin@pivotal.io" \ + -H "Authorization: Bearer ${CLOUDFLARE_CACHE_TOKEN}" \ + -H "Content-Type: application/json" \ + --data "${json}" + + json="" + counter=0 + fi +done +if ! [[ "$counter" -eq 0 ]]; then + json="${json::-2}${NL}]}" + echo $json + + curl -X DELETE "https://api.cloudflare.com/client/v4/zones/${CLOUDFLARE_ZONE_ID}/purge_cache" \ + -H "X-Auth-Email: spring-sysadmin@pivotal.io" \ + -H "Authorization: Bearer ${CLOUDFLARE_CACHE_TOKEN}" \ + -H "Content-Type: application/json" \ + --data "${json}" +fi diff --git a/.github/workflows/eclipse-ls-extensions-build.yml b/.github/workflows/eclipse-ls-extensions-build.yml index 3d8400530..265e5e35a 100644 --- a/.github/workflows/eclipse-ls-extensions-build.yml +++ b/.github/workflows/eclipse-ls-extensions-build.yml @@ -89,7 +89,7 @@ jobs: CLOUDFLARE_CACHE_TOKEN: ${{ secrets.CLOUDFLARE_CACHE_TOKEN }} run: | dist_path=`cat ${{ github.workspace }}/eclipse-language-servers/org.springframework.tooling.ls.integration.repository/target/s3-p2-repo-dist-path.txt` - echo $dist_path + ${{ github.workspace }}/.github/scripts/clear-s3-caches.sh $dist_path - name: Verify Eclipse LS Extensions on e429 if: ${{ inputs.build_type == 'snapshot' }} run: | diff --git a/.github/workflows/gh-hosted-eclipse-distro-build.yml b/.github/workflows/gh-hosted-eclipse-distro-build.yml index 18a83e06d..8f633baea 100644 --- a/.github/workflows/gh-hosted-eclipse-distro-build.yml +++ b/.github/workflows/gh-hosted-eclipse-distro-build.yml @@ -100,7 +100,7 @@ jobs: CLOUDFLARE_CACHE_TOKEN: ${{ secrets.CLOUDFLARE_CACHE_TOKEN }} run: | dist_path=`cat ${{ github.workspace }}/eclipse-distribution/org.springframework.boot.ide.product.${{ inputs.eclipse_profile }}/target/s3-p2-repo-dist-path.txt` - echo $dist_path + ${{ github.workspace }}/.github/scripts/clear-s3-caches.sh $dist_path - name: Update Nightly Distro Downloads page if: ${{ inputs.build_type == 'snapshot' && always() }} env: @@ -308,7 +308,7 @@ jobs: CLOUDFLARE_CACHE_TOKEN: ${{ secrets.CLOUDFLARE_CACHE_TOKEN }} run: | dist_path=`cat s3-dist-path.txt` - echo $dist_path + ${{ github.workspace }}/.github/scripts/clear-s3-caches.sh $dist_path - name: Remove Temp Build Artifacts from S3 id: cleanup-s3-temp-storage env: