Skip to content

Commit fafa218

Browse files
authored
[infra] Cloud Build/Run artifact cleanup (#831)
* Add cleanup script as private package * Add cloudbuild yaml file to run script on trigger
1 parent b8e2b2e commit fafa218

File tree

7 files changed

+2230
-2
lines changed

7 files changed

+2230
-2
lines changed

cloudbuild-cleanup.yaml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# lit.dev Cloud Build config for cleanup of build artifacts
2+
#
3+
# https://cloud.google.com/cloud-build/docs/build-config
4+
5+
steps:
6+
- id: cleanup
7+
name: node:16
8+
script: |
9+
cd packages/lit-dev-cloudbuild-cleanup
10+
npm ci
11+
npm run build
12+
npm start
13+
env:
14+
- 'PROJECT_ID=$PROJECT_ID'
15+
- 'REPO_NAME=$REPO_NAME'
16+
- '_DEPLOY_REGION=$_DEPLOY_REGION'
17+
18+
tags:
19+
- lit-dev
20+
- cloudbuild-cleanup
21+
22+
options:
23+
machineType: 'N1_HIGHCPU_8'
24+
25+
timeout: 45m

cloudbuild-main.yaml

+6-2
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ steps:
3737
- '--image=$_GCR_HOSTNAME/$PROJECT_ID/$REPO_NAME/lit-dev:$COMMIT_SHA'
3838
- '--quiet'
3939
- '--no-traffic'
40+
# If this tag format changes, also update route-traffic- steps below and
41+
# the cleanup script in packages/lit-dev-cloudbuild-cleanup/src/cleanup.ts
4042
- '--tag=main-$SHORT_SHA'
4143
# IMPORTANT: If you change --memory, be sure to also change
4244
# --max-old-space-size in ./Dockerfile, and this same flag in
@@ -70,6 +72,8 @@ steps:
7072
- '--image=$_GCR_HOSTNAME/$PROJECT_ID/$REPO_NAME/lit-dev:$COMMIT_SHA'
7173
- '--quiet'
7274
- '--no-traffic'
75+
# If this tag format changes, also update route-traffic- steps below and
76+
# the cleanup script in packages/lit-dev-cloudbuild-cleanup/src/cleanup.ts
7377
- '--tag=main-$SHORT_SHA'
7478
# IMPORTANT: If you change --memory, be sure to also change
7579
# --max-old-space-size in ./Dockerfile, and this same flag in
@@ -119,8 +123,8 @@ steps:
119123
- beta
120124
- run
121125
- services
122-
- update-traffic # Service name
123-
- lit-dev-playground
126+
- update-traffic
127+
- lit-dev-playground # Service name
124128
- '--region=$_DEPLOY_REGION'
125129
- '--platform=managed'
126130
- '--quiet'

cloudbuild-pr.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ steps:
2222
- --cache=true
2323
- --cache-ttl=168h # 1 week
2424
- --build-arg=LITDEV_ENV=pr
25+
# If this tag format changes, also update the cleanup script in
26+
# packages/lit-dev-cloudbuild-cleanup/src/cleanup.ts
2527
- --build-arg=REVISION_TAG=pr$_PR_NUMBER-$SHORT_SHA
2628
- --build-arg=SHORT_SHA=$SHORT_SHA
2729

@@ -42,6 +44,8 @@ steps:
4244
- '--image=$_GCR_HOSTNAME/$PROJECT_ID/$REPO_NAME/lit-dev:$COMMIT_SHA'
4345
- '--quiet'
4446
- '--no-traffic'
47+
# If this tag format changes, also update the cleanup script in
48+
# packages/lit-dev-cloudbuild-cleanup/src/cleanup.ts
4549
- '--tag=pr$_PR_NUMBER-$SHORT_SHA'
4650
# IMPORTANT: If you change --memory, be sure to also change
4751
# --max-old-space-size in ./Dockerfile, and this same flag in
@@ -75,6 +79,8 @@ steps:
7579
- '--image=$_GCR_HOSTNAME/$PROJECT_ID/$REPO_NAME/lit-dev:$COMMIT_SHA'
7680
- '--quiet'
7781
- '--no-traffic'
82+
# If this tag format changes, also update the cleanup script in
83+
# packages/lit-dev-cloudbuild-cleanup/src/cleanup.ts
7884
- '--tag=pr$_PR_NUMBER-$SHORT_SHA'
7985
# IMPORTANT: If you change --memory, be sure to also change
8086
# --max-old-space-size in ./Dockerfile, and this same flag in

0 commit comments

Comments
 (0)