Skip to content

Commit

Permalink
remove PR environments when PR closes
Browse files Browse the repository at this point in the history
  • Loading branch information
TimHess committed Feb 26, 2024
1 parent 64a512e commit 9072cb5
Showing 1 changed file with 31 additions and 32 deletions.
63 changes: 31 additions & 32 deletions .github/workflows/pr-cleanup.yml
Original file line number Diff line number Diff line change
@@ -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
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 }}

0 comments on commit 9072cb5

Please sign in to comment.