From 0cd3731a966d9f4e5581e15f9d6b4c9ac697ddbe Mon Sep 17 00:00:00 2001 From: aboyko Date: Fri, 17 Nov 2023 09:58:08 -0500 Subject: [PATCH] GHA: Batch URIs to invalidate on Akamai --- .github/actions/akamai-purge-osx/action.yml | 25 ++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/.github/actions/akamai-purge-osx/action.yml b/.github/actions/akamai-purge-osx/action.yml index 59c56e9b4..d3ba1f2f7 100644 --- a/.github/actions/akamai-purge-osx/action.yml +++ b/.github/actions/akamai-purge-osx/action.yml @@ -21,7 +21,30 @@ runs: - name: Purge shell: bash run: | - akamai purge --edgerc ~/.edgerc --section ccu ${{ inputs.command }} ${{ inputs.urls }} + MAX=50000 + urls=${{ inputs.urls }} + if [ ${#urls} -ge $MAX ]; then + echo "Too many URLs. Splitting URLS in batches..." + indices=`echo $urls | grep -o -b " "` + offset=0 + length=0 + for idx in $indices + do + end=${idx%:*} + new_length=$((end-start)) + if [ $new_length -ge $MAX ]; then + batch=${urls:offset:length} + echo $batch + start=$((offset + length)) + length=$((end - start)) + else + length=$new_length + fi + done + else + echo "Executing single Purge command..." + akamai purge --edgerc ~/.edgerc --section ccu ${{ inputs.command }} $urls + fi - name: Cleanup if: ${{ always() }} shell: bash