[GHA] Cleanup and cache purge via cloudflare action
This commit is contained in:
47
.github/workflows/cloudflare-clear-cache-s3-dir.yml
vendored
Normal file
47
.github/workflows/cloudflare-clear-cache-s3-dir.yml
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
name: Cloudflare Purge Cache for Directory
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
s3-url:
|
||||
description: S3 URL
|
||||
required: true
|
||||
type: string
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
s3-url:
|
||||
description: S3 URL
|
||||
required: false
|
||||
type: string
|
||||
default: /snapshot/TOOLS/sts4/nightly/e4.32/
|
||||
|
||||
env:
|
||||
AWS_ACCESS_KEY_ID: ${{ secrets.CDN_S3_ACCESS_KEY }}
|
||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.CDN_S3_SECRET_KEY }}
|
||||
AWS_DEFAULT_REGION: us-east-1
|
||||
AWS_ENDPOINT_URL_S3: ${{ secrets.CDN_S3_ENDPOINT }}
|
||||
AWS_S3_BUCKET: ${{ secrets.CDN_BUCKET }}/spring-tools
|
||||
DOWNLOAD_URL_ROOT: https://cdn.spring.io/spring-tools
|
||||
|
||||
jobs:
|
||||
|
||||
clear-cache-s3-dir:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Prepare URLs
|
||||
id: prepare-urls
|
||||
run: |
|
||||
ESCAPED_REPLACE_URL=$(printf '%s\n' "$DOWNLOAD_URL_ROOT/" | sed -e 's/[\/&]/\\&/g')
|
||||
sed_pattern="s/^[ \t]*/$ESCAPED_REPLACE_URL/"
|
||||
urls=`aws s3 ls s3://$AWS_S3_BUCKET${{ inputs.s3-url }} --recursive | awk '{$1=$2=$3=""; print $0}' | sed -e "$sed_pattern" | paste -sd' ' -`
|
||||
echo "urls=$urls" >> $GITHUB_OUTPUT
|
||||
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
|
||||
with:
|
||||
sparse-checkout: |
|
||||
.github
|
||||
- uses: ./.github/actions/cloudflare-purge
|
||||
name: Invalidate Cache for URLs
|
||||
with:
|
||||
urls: ${{ steps.prepare-urls.outputs.urls }}
|
||||
cloudflare_zone_id: ${{ secrets.CLOUDFLARE_ZONE_ID }}
|
||||
cloudflare_cache_token: ${{ secrets.CLOUDFLARE_CACHE_TOKEN }}
|
||||
Reference in New Issue
Block a user