From 745fa71c6c8d34c70fb9662e85e0f3968a9197ba Mon Sep 17 00:00:00 2001 From: "Mark E. Haase" Date: Wed, 21 Feb 2024 11:23:29 -0500 Subject: [PATCH] ci: update web builds - Add concurrency directive to prevent simultaneous builds for a single branch. - Add a workflow to delete the web preview when a PR is closed. --- .github/workflows/delete-web-preview.yml | 24 ++++++++++++++++++++++++ .github/workflows/editor-build.yml | 13 +++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 .github/workflows/delete-web-preview.yml diff --git a/.github/workflows/delete-web-preview.yml b/.github/workflows/delete-web-preview.yml new file mode 100644 index 0000000..bc4fb3f --- /dev/null +++ b/.github/workflows/delete-web-preview.yml @@ -0,0 +1,24 @@ +name: Delete Preview Build + +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: mappingseditor + 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/*" diff --git a/.github/workflows/editor-build.yml b/.github/workflows/editor-build.yml index 81293cc..844fc49 100644 --- a/.github/workflows/editor-build.yml +++ b/.github/workflows/editor-build.yml @@ -5,6 +5,19 @@ on: branches: [main] pull_request: +# If another web build starts for the same branch, cancel the previous build. This +# protects us from two builds 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 + pages: write + pull-requests: write + jobs: mappings_editor_build: runs-on: ubuntu-latest