From 5b2866c2bc2f76cf17ccd1d14b9b1260a059657a Mon Sep 17 00:00:00 2001 From: "Mark E. Haase" Date: Tue, 20 Feb 2024 13:08:42 -0500 Subject: [PATCH] Update web build 1. Add the concurrency directive to hopefully avoid having any parallel builds of the same branch, which could lead to two builds uploading web files at the same time. 2. Add a delete-web-preview workflow that runs whenever a PR is closed to delete the temporary web build for that branch. --- .github/workflows/build-web.yml | 7 +++++++ .github/workflows/delete-web-preview.yml | 24 ++++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 .github/workflows/delete-web-preview.yml diff --git a/.github/workflows/build-web.yml b/.github/workflows/build-web.yml index fa53f48c..f4871e98 100644 --- a/.github/workflows/build-web.yml +++ b/.github/workflows/build-web.yml @@ -5,6 +5,13 @@ on: branches: [main] pull_request: +# If another web build starts for the same branch, cancel the previous build. This +# protects us from two build trying to upload at the same time and clobbering each +# other. +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + permissions: contents: read id-token: write diff --git a/.github/workflows/delete-web-preview.yml b/.github/workflows/delete-web-preview.yml new file mode 100644 index 00000000..12d60816 --- /dev/null +++ b/.github/workflows/delete-web-preview.yml @@ -0,0 +1,24 @@ +name: Build Website + +on: + pull_request: + types: [closed] + +permissions: + contents: read + id-token: write + pages: write + pull-requests: write + +jobs: + azure_blob: + runs-on: ubuntu-latest + env: + AZURE_STORAGE_ACCOUNT: mappingsexplorer + AZURE_STORAGE_SAS_TOKEN: ${{ secrets.AZURE_SAS_TOKEN }} + BRANCH_NAME: ${{ github.head_ref || github.ref_name }} + steps: + - name: Install Azure CLI + run: curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash + - name: Delete old blobs + run: az storage blob delete-batch -s '$web' --pattern "$BRANCH_NAME/*"