diff --git a/.github/workflows/build-deploy.yml b/.github/workflows/build-and-stage.yml similarity index 100% rename from .github/workflows/build-deploy.yml rename to .github/workflows/build-and-stage.yml diff --git a/.github/workflows/pr-cleanup.yml b/.github/workflows/pr-cleanup.yml new file mode 100644 index 00000000..b55924b3 --- /dev/null +++ b/.github/workflows/pr-cleanup.yml @@ -0,0 +1,32 @@ +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 diff --git a/.github/workflows/stage-prod-swap.yml b/.github/workflows/stage-prod-swap.yml new file mode 100644 index 00000000..d917fe43 --- /dev/null +++ b/.github/workflows/stage-prod-swap.yml @@ -0,0 +1,22 @@ +name: Swap staging slot contents into production + +on: + workflow_dispatch: + +jobs: + promote-to-production: + name: Promote to production + runs-on: ubuntu-latest + environment: + name: 'Production' + url: 'https://${{ vars.AZURE_WEBAPP_NAME }}.azurewebsites.net/' + + steps: + - name: Log into Azure CLI with service principal + uses: azure/login@v1 + with: + creds: ${{ secrets.AZURE_CREDENTIALS }} + + - name: Swap slots + run: az webapp deployment slot swap -s ${{ vars.STAGING_SLOT_NAME }} -n ${{ vars.AZURE_WEBAPP_NAME }} -g ${{ vars.AZURE_RESOURCE_GROUP }} + \ No newline at end of file