From 9072cb5c99be605482876f76bd9fcbdff000aa15 Mon Sep 17 00:00:00 2001 From: Tim Hess Date: Mon, 26 Feb 2024 13:57:09 -0600 Subject: [PATCH] remove PR environments when PR closes --- .github/workflows/pr-cleanup.yml | 63 ++++++++++++++++---------------- 1 file changed, 31 insertions(+), 32 deletions(-) diff --git a/.github/workflows/pr-cleanup.yml b/.github/workflows/pr-cleanup.yml index b55924b3..3169b45b 100644 --- a/.github/workflows/pr-cleanup.yml +++ b/.github/workflows/pr-cleanup.yml @@ -1,32 +1,31 @@ -name: Delete a preview environment - -on: - pull_request: - types: [closed] - -env: - SLOT_NAME: pr-${{ github.event.number }} - -jobs: - delete-slot: - runs-on: ubuntu-latest - - steps: - - name: Log into Azure CLI with service principal - uses: azure/login@v1 - with: - creds: ${{ secrets.AZURE_CREDENTIALS }} - - - name: Delete slot on staging site - run: az webapp deployment slot delete --resource-group ${{ vars.AZURE_RESOURCE_GROUP }} --name ${{ vars.AZURE_WEBAPP_NAME}} --slot ${{ env.SLOT_NAME }} - - delete-deployment: - runs-on: ubuntu-latest - - steps: - - name: Delete Deployment Environment - uses: strumwolf/delete-deployment-environment@v2 - with: - environment: "pr-${{ github.event.number }}" - token: ${{ secrets.GITHUB_TOKEN }} - onlyRemoveDeployments: true \ No newline at end of file +name: Delete a preview environment + +on: + pull_request: + types: [closed] + +env: + SLOT_NAME: pr-${{ github.event.number }} + +jobs: + delete-slot: + runs-on: ubuntu-latest + + steps: + - name: Log into Azure CLI with service principal + uses: azure/login@v1 + with: + creds: ${{ secrets.AZURE_CREDENTIALS }} + + - name: Delete slot on staging site + run: az webapp deployment slot delete --resource-group ${{ vars.AZURE_RESOURCE_GROUP }} --name ${{ vars.AZURE_WEBAPP_NAME}} --slot ${{ env.SLOT_NAME }} + + delete-deployment: + runs-on: ubuntu-latest + + steps: + - name: Delete Deployment Environment + uses: strumwolf/delete-deployment-environment@v3 + with: + environment: "pr-${{ github.event.number }}" + token: ${{ secrets.GITHUB_TOKEN }}