-
Notifications
You must be signed in to change notification settings - Fork 66
38 lines (30 loc) · 1.12 KB
/
cleanup.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
name: 'Cleanup'
on:
schedule:
- cron: '0 */6 * * *'
workflow_dispatch:
permissions:
contents: 'read'
id-token: 'write'
jobs:
cleanup:
runs-on: 'ubuntu-latest'
steps:
- uses: 'actions/checkout@v4'
- uses: 'google-github-actions/auth@v2'
with:
workload_identity_provider: '${{ vars.WIF_PROVIDER_NAME }}'
service_account: '${{ vars.SERVICE_ACCOUNT_EMAIL }}'
- uses: 'google-github-actions/setup-gcloud@v2'
- name: Delete services
run: |-
gcloud config set core/project "${{ vars.PROJECT_ID }}"
gcloud config set functions/region "us-central1"
# List and delete all functions that were deployed 30 minutes ago or
# earlier. The date math here is a little weird, but we're looking for
# deployments "earlier than" 30 minutes ago, so it's less than since
# time increases.
(IFS=$'\n'; for NAME in $(gcloud functions list --format="value(name)" --filter="updateTime < '-pt30m'"); do
echo "Deleting ${NAME}..."
gcloud functions delete ${NAME} --quiet
done)