From 1fc7daf3b27e39ebebbc85b6cf4a3f1aca959581 Mon Sep 17 00:00:00 2001 From: aboyko Date: Fri, 29 Sep 2023 12:14:49 -0400 Subject: [PATCH] GHA: draft upload of nightly-distributions page --- .github/scripts/clear-s3-caches-pattern.sh | 66 +++++++++++++++++++ .../snapshot-eclipse-ls-extensions-build.yml | 6 +- .../upload-nightly-downloads-page.yml | 35 ++++++++++ 3 files changed, 104 insertions(+), 3 deletions(-) create mode 100755 .github/scripts/clear-s3-caches-pattern.sh create mode 100644 .github/workflows/upload-nightly-downloads-page.yml diff --git a/.github/scripts/clear-s3-caches-pattern.sh b/.github/scripts/clear-s3-caches-pattern.sh new file mode 100755 index 000000000..7ba02e761 --- /dev/null +++ b/.github/scripts/clear-s3-caches-pattern.sh @@ -0,0 +1,66 @@ +set -e + +pattern=$1 + +echo "Clearing S3 caches for path: ${s3_path}" + +#Flush AWS Cloudfront Cache +echo 'aws cloudfront create-invalidation --distribution-id ECAO9Q8651L8M --output json --paths "/${pattern}"' + +#invalidation_json=`aws cloudfront create-invalidation --distribution-id ECAO9Q8651L8M --output json --paths "/${pattern}"` +#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}" + +# Flush CloudFlare Cache +s3_url=s3://dist.springsource.com/ +files=`aws s3 cp ${s3_url} . --recursive --include "${pattern}" --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%,*}${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%,*}${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/snapshot-eclipse-ls-extensions-build.yml b/.github/workflows/snapshot-eclipse-ls-extensions-build.yml index b3c765b09..79e42f0d2 100644 --- a/.github/workflows/snapshot-eclipse-ls-extensions-build.yml +++ b/.github/workflows/snapshot-eclipse-ls-extensions-build.yml @@ -6,9 +6,9 @@ concurrency: on: workflow_dispatch: - push: - branches: - - 'main' +# push: +# branches: +# - 'main' jobs: eclipse-ls-extensions: diff --git a/.github/workflows/upload-nightly-downloads-page.yml b/.github/workflows/upload-nightly-downloads-page.yml new file mode 100644 index 000000000..22a27713d --- /dev/null +++ b/.github/workflows/upload-nightly-downloads-page.yml @@ -0,0 +1,35 @@ +name: Upload nightly-distributions.html form the Repo to S3 + +on: + workflow_dispatch: + +jobs: + + upload-nightly-downloads-s3-cache: + runs-on: macos-latest + steps: + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 + with: + ref: ${{ inputs.ref }} + sparse-checkout: | + .github + eclipse-distribution/common/html + - name: Upload nightly-distributions.html + env: + AWS_ACCESS_KEY_ID: ${{ secrets.TOOLS_S3_ACCESS_KEY }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.TOOLS_S3_SECRET_KEY }} + AWS_DEFAULT_REGION: us-east-1 + run: | + echo "Removing old nightly-distributions.html from s3..." + aws s3 rm s3://dist.springsource.com/snapshot/STS4/nightly-distributions.html --dryrun + echo "Uploading new nightly-distributions.html to s3..." + aws s3 cp ./eclipse-distribution/common/html/nightly-distributions.html s3://dist.springsource.com/snapshot/STS4/nightly-distributions.html --acl public-read --no-progress --dryrun + - name: Invalidate S3 Cloudfront Cache + env: + 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: | + ${{ github.workspace }}/.github/scripts/clear-s3-caches-pattern.sh snapshot/STS4/nightly-distributions.html