Skip to content

Commit 2f8457f

Browse files
authored
build(librarian): add GCB configs for update-image (#2802)
Towards #2800
1 parent 53bdb77 commit 2f8457f

File tree

6 files changed

+102
-4
lines changed

6 files changed

+102
-4
lines changed

infra/prod/generate-worker.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,5 @@ steps:
2323
- '--push=$_PUSH'
2424
- '--build=$_BUILD'
2525
tags: ['generate-dispatcher']
26-
availableSecrets:
2726
options:
2827
logging: CLOUD_LOGGING_ONLY

infra/prod/stage-release-worker.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,5 @@ steps:
2323
- '--push=$_PUSH'
2424
- '--force-run=$_FORCE_RUN'
2525
tags: ['stage-release-dispatcher']
26-
availableSecrets:
2726
options:
2827
logging: CLOUD_LOGGING_ONLY
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
15+
# This triggers the `update-image` workflow for all repositories registered
16+
# to automate the `librarian update-image` command
17+
steps:
18+
- name: us-central1-docker.pkg.dev/cloud-sdk-librarian-prod/images-prod/librarian-dispatcher
19+
id: update-image-dispatcher
20+
args:
21+
- '--project=$PROJECT_ID'
22+
- '--command=update-image'
23+
- '--push=$_PUSH'
24+
- '--build=$_BUILD'
25+
tags: ['update-image-dispatcher']
26+
options:
27+
logging: CLOUD_LOGGING_ONLY

infra/prod/update-image.yaml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
15+
# This runs the `librarian update-image` command with a provided repository,
16+
# secret name, and optional library ID
17+
steps:
18+
- name: gcr.io/cloud-builders/git
19+
id: clone-language-repo
20+
waitFor: ['-']
21+
args:
22+
- 'clone'
23+
- '--depth=1'
24+
- '--branch=$_BRANCH'
25+
- $_FULL_REPOSITORY
26+
- name: gcr.io/cloud-builders/git
27+
id: configure-language-repo-name
28+
waitFor: ['clone-language-repo']
29+
dir: /workspace/$_REPOSITORY
30+
args:
31+
- 'config'
32+
- 'user.name'
33+
- 'Cloud SDK Librarian'
34+
- name: gcr.io/cloud-builders/git
35+
id: configure-language-repo-email
36+
waitFor: ['configure-language-repo-name']
37+
dir: /workspace/$_REPOSITORY
38+
args:
39+
- 'config'
40+
- 'user.email'
41+
42+
- name: gcr.io/cloud-builders/git
43+
id: clone-googleapis
44+
waitFor: ['-']
45+
args:
46+
- 'clone'
47+
- '--single-branch'
48+
- '--branch=master'
49+
- https://github.com/googleapis/googleapis
50+
- name: 'us-central1-docker.pkg.dev/cloud-sdk-librarian-prod/images-prod/librarian@sha256:5a001095dcee6b6fdaf3f826a4a339853786b55b21f571daefdfffa995e01272'
51+
id: update-image
52+
waitFor: ['configure-language-repo-email', 'clone-googleapis']
53+
dir: tmp
54+
args:
55+
- 'update-image'
56+
- '-repo'
57+
- '/workspace/$_REPOSITORY'
58+
- '-api-source'
59+
- '/workspace/googleapis'
60+
- '-branch=$_BRANCH'
61+
- '-commit=true'
62+
- '-push=$_PUSH'
63+
- '-build=$_BUILD'
64+
secretEnv: ['LIBRARIAN_GITHUB_TOKEN']
65+
tags: ['update-image-$_REPOSITORY']
66+
availableSecrets:
67+
secretManager:
68+
- versionName: projects/$PROJECT_ID/secrets/$_GITHUB_TOKEN_SECRET_NAME/versions/latest
69+
env: 'LIBRARIAN_GITHUB_TOKEN'
70+
options:
71+
logging: CLOUD_LOGGING_ONLY
72+
timeout: 10h

internal/automation/repositories.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ var availableCommands = map[string]bool{
3030
"generate": true,
3131
"stage-release": true,
3232
"publish-release": true,
33+
"update-image": true,
3334
}
3435

3536
// RepositoryConfig represents a single registered librarian GitHub repository.

internal/automation/trigger.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ var triggerNameByCommandName = map[string]string{
3535
"generate": "generate",
3636
"stage-release": "stage-release",
3737
"publish-release": "publish-release",
38+
"update-image": "update-image",
3839
}
3940

4041
const region = "global"
@@ -134,8 +135,7 @@ func runCommandWithConfig(ctx context.Context, client CloudBuildClient, ghClient
134135
} else {
135136
substitutions["_PR"] = fmt.Sprintf("%v", prs[0].GetHTMLURL())
136137
}
137-
} else if command == "generate" {
138-
// only pass _BUILD to generate trigger
138+
} else if command == "generate" || command == "update-image" {
139139
substitutions["_BUILD"] = fmt.Sprintf("%v", build)
140140
}
141141
err = runCloudBuildTriggerByName(ctx, client, projectId, region, triggerName, substitutions)

0 commit comments

Comments
 (0)