[GHA-Build] Putting everything together for release builds and cache clearance

This commit is contained in:
aboyko
2023-07-31 19:36:49 -04:00
parent 7cd8d66d35
commit 849051e62e
3 changed files with 46 additions and 44 deletions

View File

@@ -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