forked from liferay/liferay-portal
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathci-clean-up-cloud-non-production-artifacts.yaml
More file actions
67 lines (59 loc) · 2.46 KB
/
Copy pathci-clean-up-cloud-non-production-artifacts.yaml
File metadata and controls
67 lines (59 loc) · 2.46 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
defaults:
run:
shell: bash
jobs:
clean-up-artifacts:
env:
BOOTSTRAP_STORAGE_PATH_NONPRODUCTION: ${{vars.BOOTSTRAP_STORAGE_PATH_NONPRODUCTION}}
EVENT_REF: ${{github.event.ref}}
HELM_CHART_REGISTRY_NONPRODUCTION: ${{vars.HELM_CHART_REGISTRY_NONPRODUCTION}}
if: |-
${{
github.event.ref_type == 'branch' &&
github.repository == 'cloudnative-team/liferay-portal' &&
(
startsWith(github.event.ref, 'LCD-') ||
startsWith(github.event.ref, 'release/')
)
}}
runs-on: ubuntu-latest
steps:
- name: Authenticate to Google Cloud
uses: google-github-actions/auth@v3
with:
project_id: ${{vars.GCP_PROJECT_ID_EXTERNAL_NONPRODUCTION}}
workload_identity_provider: ${{vars.GCP_WORKLOAD_IDENTITY_PROVIDER_EXTERNAL_NONPRODUCTION}}
- name: Set up Google Cloud CLI
uses: google-github-actions/setup-gcloud@v2
with:
project_id: ${{vars.GCP_PROJECT_ID_EXTERNAL_NONPRODUCTION}}
- name: Clean up Helm chart images
run: |
set -o errexit
set -o nounset
set -o pipefail
function main {
local registry_path="${HELM_CHART_REGISTRY_NONPRODUCTION}/$(echo "${EVENT_REF}" | tr 'A-Z/' 'a-z-')"
local images
images=$(gcloud artifacts docker images list "${registry_path}" --format="value(package)" | sort --unique) || true
local image
for image in ${images}
do
gcloud artifacts docker images delete "${image}" --delete-tags --quiet || true
done
}
main "${@}"
- name: Clean up bootstrap tarballs
run: |
set -o errexit
set -o nounset
set -o pipefail
function main {
gcloud storage rm --recursive "${BOOTSTRAP_STORAGE_PATH_NONPRODUCTION}/$(echo "${EVENT_REF}" | tr '/' '-')/" || true
}
main "${@}"
on:
delete
permissions:
contents: read
id-token: write