-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathcloudbuild.yaml
96 lines (90 loc) · 2.97 KB
/
cloudbuild.yaml
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# gcloud builds submit --config=cloudbuild.yaml --project=project-name --substitutions=TAG="v0.65"
steps:
#publish latest cosign
- name: 'gcr.io/cloud-builders/docker'
id: build_cosign
args:
- 'build'
- '-t'
- '${_COSIGN_IMAGE_NAME}:latest'
- '-f'
- 'Dockerfile.cosign'
- '.'
- name: 'gcr.io/cloud-builders/docker'
id: push_cosign
args: ['push', '${_COSIGN_IMAGE_NAME}:latest']
#publish integrationcli
- name: 'gcr.io/cloud-builders/docker'
id: build_integrationcli
args:
- 'build'
- '-t'
- '${_IMAGE_NAME}:${TAG_NAME}'
- '-f'
- 'Dockerfile'
- '.'
- '--build-arg'
- 'TAG=${TAG_NAME}'
- '--build-arg'
- 'COMMIT=$COMMIT_SHA'
- name: 'gcr.io/cloud-builders/docker'
id: push_integrationcli
args: ['push', '${_IMAGE_NAME}:${TAG_NAME}']
- name: 'gcr.io/cloud-builders/docker'
id: tag_latest_integrationcli
args: ['tag', '${_IMAGE_NAME}:${TAG_NAME}', '${_IMAGE_NAME}:latest']
- name: 'gcr.io/cloud-builders/docker'
id: push_latest_integrationcli
args: ['push', '${_IMAGE_NAME}:latest']
#sign and attach integrationcli
- name: 'us-docker.pkg.dev/${PROJECT_ID}/${_REPO}/cosign:latest'
id: sign_integrationcli
entrypoint: 'sh'
secretEnv: ['COSIGN_PASSWORD', 'COSIGN_PRIVATE_KEY']
args:
- -c
- |
echo "$$COSIGN_PRIVATE_KEY" > /tmp/cosign.key
cosign sign --key=/tmp/cosign.key --output-signature=/tmp/integrationcli_${TAG_NAME}.sig --yes ${_IMAGE_NAME}:${TAG_NAME}
cosign attach signature --signature=/tmp/integrationcli_${TAG_NAME}.sig ${_IMAGE_NAME}:${TAG_NAME}
- name: "gcr.io/google.com/cloudsdktool/cloud-sdk"
id: export_sbom
entrypoint: gcloud
args:
- artifacts
- sbom
- export
- --uri=${_IMAGE_NAME}:${TAG_NAME}
- --project=${PROJECT_ID}
availableSecrets:
secretManager:
- versionName: projects/$PROJECT_ID/secrets/integrationcli-cosign-password/versions/latest
env: 'COSIGN_PASSWORD'
- versionName: projects/$PROJECT_ID/secrets/integrationcli-cosign-private-key/versions/latest
env: 'COSIGN_PRIVATE_KEY'
images:
- '${_IMAGE_NAME}:${TAG_NAME}'
#repo name
substitutions:
_REPO: "images"
_IMAGE_NAME: "us-docker.pkg.dev/${PROJECT_ID}/${_REPO}/integrationcli"
_COSIGN_IMAGE_NAME: "us-docker.pkg.dev/${PROJECT_ID}/${_REPO}/cosign"
options:
machineType: E2_HIGHCPU_8
logging: CLOUD_LOGGING_ONLY
substitution_option: ALLOW_LOOSE
dynamic_substitutions: true
requestedVerifyOption: VERIFIED