-
Notifications
You must be signed in to change notification settings - Fork 18
44 lines (36 loc) · 1.15 KB
/
clear-deployment-history.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
name: Clear Deployment History
on:
workflow_dispatch:
# schedule:
# - cron: "0 0/4 * * *"
permissions:
contents: read
id-token: write
issues: write
pull-requests: write
jobs:
delete-deployment-history:
name: "Deleting Deployment History"
if: github.repository_owner == 'aliencube'
runs-on: ubuntu-latest
env:
AZURE_CLIENT_ID: ${{ vars.AZM_CLIENT_ID }}
AZURE_TENANT_ID: ${{ vars.AZM_TENANT_ID }}
AZURE_SUBSCRIPTION_ID: ${{ vars.AZM_SUBSCRIPTION_ID }}
steps:
- name: Azure login (Federated Credentials)
if: env.AZURE_CLIENT_ID != ''
uses: azure/login@v2
with:
client-id: ${{ env.AZURE_CLIENT_ID }}
tenant-id: ${{ env.AZURE_TENANT_ID }}
subscription-id: ${{ env.AZURE_SUBSCRIPTION_ID }}
enable-AzPSSession: true
- name: Delete all deployment history
shell: pwsh
run: |
$history = az deployment sub list --query "[].name" | ConvertFrom-Json
$history | ForEach-Object {
$name = $_
az deployment sub delete --name $name --no-wait
}