diff --git a/.github/workflows/CI_emscripten.yml b/.github/workflows/CI_emscripten.yml index bf4bed5d0f2..6c501e033c0 100644 --- a/.github/workflows/CI_emscripten.yml +++ b/.github/workflows/CI_emscripten.yml @@ -203,6 +203,7 @@ jobs: built-commit-sha: ${{ needs.web-build.outputs.WZ_GITHUB_SHA }} release: false ssh-dest-host: ${{ vars.WZ_WEB_BUILD_UPLOAD_SSH_HOST }} + cdn-purge-base-url: 'play.wz2100.net/dev' secrets: inherit publish_release_build: @@ -224,4 +225,5 @@ jobs: built-commit-sha: ${{ needs.web-build.outputs.WZ_GITHUB_SHA }} release: true ssh-dest-host: ${{ vars.WZ_WEB_BUILD_UPLOAD_SSH_HOST }} + cdn-purge-base-url: 'play.wz2100.net/release' secrets: inherit diff --git a/.github/workflows/publish_web_build.yml b/.github/workflows/publish_web_build.yml index f94989635ff..bd61c4bd0f6 100644 --- a/.github/workflows/publish_web_build.yml +++ b/.github/workflows/publish_web_build.yml @@ -30,6 +30,10 @@ on: description: 'The destination HOST for the rsync' required: true type: string + cdn-purge-base-url: + description: 'The base URL for CDN cache purging' + required: false + type: string secrets: WZ_WEB_BUILD_UPLOAD_SSH_KEY: required: true @@ -52,6 +56,7 @@ jobs: WASM_ARCHITECTURE: ${{ inputs.architecture }} WZ_GITHUB_REF: ${{ inputs.built-ref }} WZ_IS_RELEASE: ${{ inputs.release }} + INPUT_CDN_PURGE_BASE_URL: ${{ inputs.cdn-purge-base-url }} run: | mkdir dl-archive CHANGELOG_DIR="${GITHUB_WORKSPACE}/temp/changes" @@ -67,7 +72,7 @@ jobs: if [ "${WASM_ARCHITECTURE}" == "wasm32" ]; then WZ_UPLOAD_SUBDIR="" fi - # Determine upload path + # Determine upload path - always starts with a slash if [ "${WZ_IS_RELEASE}" == "true" ]; then SOURCE_TAG="${WZ_GITHUB_REF#refs/tags/}" WZ_UPLOAD_PATH="/${SOURCE_TAG}/${WZ_UPLOAD_SUBDIR}" @@ -76,6 +81,10 @@ jobs: fi echo "WZ_UPLOAD_PATH=${WZ_UPLOAD_PATH}" >> $GITHUB_ENV echo "WZ_UPLOAD_PATH=${WZ_UPLOAD_PATH}" >> $GITHUB_OUTPUT + # Determine base CDN url path (remove any trailing slashes) + WZ_CDN_BASE_URL="$(echo "${INPUT_CDN_PURGE_BASE_URL}" | sed 's:/*$::')" + echo "WZ_CDN_BASE_URL=${WZ_CDN_BASE_URL}" >> $GITHUB_ENV + echo "WZ_CDN_BASE_URL=${WZ_CDN_BASE_URL}" >> $GITHUB_OUTPUT - name: Download Archive Artifact uses: actions/download-artifact@v4 with: @@ -138,6 +147,7 @@ jobs: rm ~/.ssh/id_ed25519 - name: 'Generate Cloudflare Cache Purge URLs List' id: purgeurls + if: ${{ success() && env.WZ_CDN_BASE_URL != '' }} env: CHANGED_FILES_LIST: '${{ steps.fileslist.outputs.CHANGED_FILES_LIST }}' CHANGED_SW_LIST: '${{ steps.fileslist.outputs.CHANGED_SW_LIST }}' @@ -156,12 +166,13 @@ jobs: exit 1 fi # Run the gen_purge_url_batches script on the main list - python3 "./gen_purge_url_batches.py" "play.wz2100.net" "${CHANGED_FILES_LIST}" "${PURGE_URLS_DATA_FILES_DIR}" + python3 "./gen_purge_url_batches.py" "${WZ_CDN_BASE_URL}${WZ_UPLOAD_PATH}" "${CHANGED_FILES_LIST}" "${PURGE_URLS_DATA_FILES_DIR}" echo "PURGE_URLS_DATA_FILES_DIR=${PURGE_URLS_DATA_FILES_DIR}" >> $GITHUB_OUTPUT # Run the gen_purge_url_batches script on the service-worker file list - python3 "./gen_purge_url_batches.py" "play.wz2100.net" "${CHANGED_SW_LIST}" "${PURGE_SERVICEWORKER_URLS_DATA_FILES_DIR}" + python3 "./gen_purge_url_batches.py" "${WZ_CDN_BASE_URL}${WZ_UPLOAD_PATH}" "${CHANGED_SW_LIST}" "${PURGE_SERVICEWORKER_URLS_DATA_FILES_DIR}" echo "PURGE_SERVICEWORKER_URLS_DATA_FILES_DIR=${PURGE_SERVICEWORKER_URLS_DATA_FILES_DIR}" >> $GITHUB_OUTPUT - name: 'Purge Cloudflare Cache' + if: ${{ success() && env.WZ_CDN_BASE_URL != '' }} env: CLOUDFLARE_ZONE: ${{ secrets.CLOUDFLARE_WZ2100_ZONE }} CLOUDFLARE_CACHEPURGE_TOKEN: ${{ secrets.CLOUDFLARE_WZ2100_CACHEPURGE_TOKEN }}