From 77d628d74e3ae81c7929a0e70240026e7b7fd737 Mon Sep 17 00:00:00 2001 From: aboyko Date: Mon, 31 Jul 2023 17:08:18 -0400 Subject: [PATCH] [GHA-Build] debug clearing cloudflare cache --- .github/scripts/clear-s3-caches.sh | 44 +++++++++++++++++++++------- .github/workflows/clear_s3_cache.yml | 16 +++++----- 2 files changed, 42 insertions(+), 18 deletions(-) diff --git a/.github/scripts/clear-s3-caches.sh b/.github/scripts/clear-s3-caches.sh index 50a9aa558..48a1637e0 100755 --- a/.github/scripts/clear-s3-caches.sh +++ b/.github/scripts/clear-s3-caches.sh @@ -1,16 +1,38 @@ set -e s3_path=$1 -aws cloudfront create-invalidation --distribution-id ECAO9Q8651L8M --paths /release/TOOLS/sts4-language-server-integrations/2023-07-31/* -invalidation_json=`aws cloudfront create-invalidation --distribution-id ECAO9Q8651L8M --output json --paths /${s3_path}/*` -echo "Invalidation response: ${invalidation_json}" -invalidation_id=`echo $invalidation_json | jq -r '.Invalidation.Id'` -invalidation_status=`echo $invalidation_json | jq -r '.Invalidation.Status'` -echo "ID=${invalidation_id} Status=${invalidation_status}" -while [ "${invalidation_status}" == "InProgress" ] +#invalidation_json=`aws cloudfront create-invalidation --distribution-id ECAO9Q8651L8M --output json --paths "/${s3_path}/*"` +#echo "Invalidation response: ${invalidation_json}" +#invalidation_id=`echo $invalidation_json | jq -r '.Invalidation.Id'` +#invalidation_status=`echo $invalidation_json | jq -r '.Invalidation.Status'` +#echo "ID=${invalidation_id} Status=${invalidation_status}" +#while [ "${invalidation_status}" == "InProgress" ] +#do +# echo "Invalidation status: ${invalidation_status}" +# sleep 3 +# invalidation_status=`aws cloudfront get-invalidation --distribution-id ECAO9Q8651L8M --id $invalidation_id --output json | jq -r '.Invalidation.Status'` +#done +#echo "Final invalidation status: ${invalidation_status}" + +s3_url=s3://dist.springsource.com/${s3_path} +files=`aws s3 cp ${s3_url} . --recursive --include "*" --dryrun` +counter=0 +json="" +for file in $files do - echo "Invalidation status: ${invalidation_status}" - sleep 3 - invalidation_status=`aws cloudfront get-invalidation --distribution-id ECAO9Q8651L8M --id $invalidation_id --output json | jq -r '.Invalidation.Status'` + if [ $counter == 0]; then + json="\"{ \"files\": [\n" + fi + if [[ "$file" =~ ^"s3://dist.springsource.com" ]]; then + let "counter++" + path=${file:26} + json="${json}\"http://dist.springsource.com${path}\",\n\"http://dist.springsource.com${path}\",\n\"http://download.springsource.com${path}\",\n\"https://download.springsource.com${path}\",\n" + fi + if [ $counter == 10]; then + json="${json:-2}\n]}" + echo $json + json="" + fi done -echo "Final invalidation status: ${invalidation_status}" + + diff --git a/.github/workflows/clear_s3_cache.yml b/.github/workflows/clear_s3_cache.yml index 5a2010f07..2cdfb2b2a 100644 --- a/.github/workflows/clear_s3_cache.yml +++ b/.github/workflows/clear_s3_cache.yml @@ -23,11 +23,13 @@ jobs: AWS_ACCESS_KEY_ID: ${{ secrets.TOOLS_S3_ACCESS_KEY }} AWS_SECRET_ACCESS_KEY: ${{ secrets.TOOLS_S3_SECRET_KEY }} AWS_DEFAULT_REGION: us-east-1 + CLOUDFLARE_ZONE_ID: ${{ secrets.CLOUDFLARE_ZONE_ID }} + CLOUDFLARE_CACHE_TOKEN: ${{ secrets.CLOUDFLARE_CACHE_TOKEN }} run: | - aws s3 cp s3://dist.springsource.com/snapshot/STS4/nightly/dist/e4.28 . --recursive --include "*" --dryrun - aws s3 cp s3://dist.springsource.com/release/TOOLS/sts4-language-server-integrations/2023-07-31 . --recursive --include "*" --dryrun - echo "Firing off invalidation request" - aws cloudfront create-invalidation --distribution-id ECAO9Q8651L8M --paths "/release/TOOLS/sts4-language-server-integrations/2023-07-31/*" - echo "List invalidations" - aws cloudfront list-invalidations --distribution-id ECAO9Q8651L8M -# ${{ github.workspace }}/.github/scripts/clear-s3-caches.sh ${{ inputs.path }} +# aws s3 cp s3://dist.springsource.com/snapshot/STS4/nightly/dist/e4.28 . --recursive --include "*" --dryrun +# aws s3 cp s3://dist.springsource.com/release/TOOLS/sts4-language-server-integrations/2023-07-31 . --recursive --include "*" --dryrun +# echo "Firing off invalidation request" +# aws cloudfront create-invalidation --distribution-id ECAO9Q8651L8M --paths "/release/TOOLS/sts4-language-server-integrations/2023-07-31/*" +# echo "List invalidations" +# aws cloudfront list-invalidations --distribution-id ECAO9Q8651L8M + ${{ github.workspace }}/.github/scripts/clear-s3-caches.sh ${{ inputs.path }}