forked from GoogleCloudPlatform/ubbagent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cloudbuild-tag.yaml
51 lines (45 loc) · 1.49 KB
/
cloudbuild-tag.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
# Used for building tagged releases.
# It updates the "latest" tag in the corresponding GCR repos
# if the current SemVer is the most recent.
#
# This does not actually build images; it copies candidates
# built in the staging project instead. These images should have
# been built by cloudbuild.yaml, which should be triggered on
# every new commit.
substitutions:
_STAGING_PROJECT_ID: null
steps:
- id: &PublishImages Publish Images
name: gcr.io/cloud-builders/docker
waitFor:
- '-'
entrypoint: bash
args:
- -ceux
- |
docker pull gcr.io/$_STAGING_PROJECT_ID/metering/ubbagent:sha_$COMMIT_SHA
docker tag gcr.io/$_STAGING_PROJECT_ID/metering/ubbagent:sha_$COMMIT_SHA gcr.io/$PROJECT_ID/metering/ubbagent:$TAG_NAME
- id: &DetermineShouldTagLatest Determine if images should be tagged latest
name: gcr.io/cloud-builders/gcloud
waitFor:
- *PublishImages
entrypoint: /bin/bash
args:
- -ceux
- echo "$(.cloudbuild/should_tag_latest.sh gcr.io/$PROJECT_ID/metering/ubbagent $TAG_NAME)" > should_tag_latest
- id: Maybe tag images latest
name: gcr.io/cloud-builders/docker
waitFor:
- *DetermineShouldTagLatest
entrypoint: /bin/bash
args:
- -ceux
- |
if [[ "$(cat should_tag_latest)" == "true" ]]; then
docker tag gcr.io/$PROJECT_ID/metering/ubbagent:$TAG_NAME gcr.io/$PROJECT_ID/metering/ubbagent:latest
docker push gcr.io/$PROJECT_ID/metering/ubbagent:latest
else
echo "Not tagging latest"
fi
images:
- gcr.io/$PROJECT_ID/metering/ubbagent:$TAG_NAME