-
Notifications
You must be signed in to change notification settings - Fork 1
54 lines (46 loc) · 1.7 KB
/
destroy-pr.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# This action will cleanup the azure resources, github secret, and github environment created for the PR once it's closed.
name: Destroy PR
on:
pull_request:
types: [closed]
branches: main
env:
AZURE_WEBAPP_NAME: gccollab-dev-pr-${{ github.event.number }}
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
SECRET_NAME: PR_${{ github.event.number }}
jobs:
azure:
name: Delete Azure Resources
runs-on: ubuntu-latest
if: ${{ !contains(github.event.pull_request.title, vars.IGNORE_DEPLOY) }}
steps:
- uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Delete Resources
uses: azure/CLI@v1
with:
azcliversion: 2.30.0
inlineScript: az group delete --name ${{ env.AZURE_WEBAPP_NAME }} --yes
secret:
name: Delete GitHub Secret
runs-on: ubuntu-latest
if: ${{ !contains(github.event.pull_request.title, vars.IGNORE_DEPLOY) }}
steps:
- name: GitHub Auth Login
shell: bash
run: gh auth login --with-token <<< ${{ env.ACCESS_TOKEN }}
- uses: actions/checkout@v3
- name: Delete Secret
run: gh secret delete "${{ env.SECRET_NAME }}"
environment:
name: Delete GitHub Environment
runs-on: ubuntu-latest
if: ${{ !contains(github.event.pull_request.title, vars.IGNORE_DEPLOY) }}
steps:
- name: Delete Environment
shell: bash
run: |
curl -X DELETE "https://api.github.com/repos/gctools-outilsgc/gccollab-frontend/environments/PR%20${{ github.event.number }}" \
-H "Authorization: token ${{ env.ACCESS_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json"