diff --git a/.github/scripts/clear-s3-caches-pattern.sh b/.github/scripts/clear-s3-caches-file.sh similarity index 53% rename from .github/scripts/clear-s3-caches-pattern.sh rename to .github/scripts/clear-s3-caches-file.sh index a99b7e6fc..03a2ef74a 100755 --- a/.github/scripts/clear-s3-caches-pattern.sh +++ b/.github/scripts/clear-s3-caches-file.sh @@ -1,19 +1,10 @@ set -e -pattern=$1 -if [ -z "$2" ]; -then - echo "undefined" - path_with_pattern=$pattern -else - echo "defined" - dir=$2 - path_with_pattern="${dir}/${pattern}" -fi -echo "Clearing S3 caches for path: ${path_with_pattern}" +file=$1 +echo "Clearing S3 caches for file: ${file}" #Flush AWS Cloudfront Cache -echo "aws cloudfront create-invalidation --distribution-id ECAO9Q8651L8M --output json --paths '${path_with_pattern}'" +echo "aws cloudfront create-invalidation --distribution-id ECAO9Q8651L8M --output json --paths '${file}'" #invalidation_json=`aws cloudfront create-invalidation --distribution-id ECAO9Q8651L8M --output json --paths "${path_with_pattern}"` #echo "Invalidation response: ${invalidation_json}" @@ -29,48 +20,14 @@ echo "aws cloudfront create-invalidation --distribution-id ECAO9Q8651L8M --outpu #echo "Final invalidation status: ${invalidation_status}" # Flush CloudFlare Cache -if [ -z "$dir" ]; -then - s3_url="s3://dist.springsource.com/" -else - s3_url="s3://dist.springsource.com/${dir}/" -fi -echo "aws s3 cp ${s3_url} . --recursive --include '${pattern}' --dryrun" -files=`aws s3 cp ${s3_url} . --recursive --include "${pattern}" --dryrun` -counter=0 -json="" -NL=$'\n' -FILES_BATCH=7 -for file in $files -do - echo "Looking at ${file}" - 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%,*}${NL}]}" - echo $json - +json="{\"files\": [ \"s3://dist.springsource.com/${file}\" ] }" +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%,*}${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}" \ diff --git a/.github/workflows/upload-nightly-downloads-page.yml b/.github/workflows/upload-nightly-downloads-page.yml index 0709fcba9..d73018313 100644 --- a/.github/workflows/upload-nightly-downloads-page.yml +++ b/.github/workflows/upload-nightly-downloads-page.yml @@ -32,4 +32,4 @@ jobs: CLOUDFLARE_ZONE_ID: ${{ secrets.CLOUDFLARE_ZONE_ID }} CLOUDFLARE_CACHE_TOKEN: ${{ secrets.CLOUDFLARE_CACHE_TOKEN }} run: | - ${{ github.workspace }}/.github/scripts/clear-s3-caches-pattern.sh nightly-distributions.html snapshot/STS4 + ${{ github.workspace }}/.github/scripts/clear-s3-caches-file.sh snapshot/STS4/nightly-distributions.html