On triggered build, write git commit to front end
This commit is contained in:
parent
81deb19830
commit
9e257200a4
3 changed files with 28 additions and 4 deletions
|
@ -9,15 +9,27 @@
|
|||
# Example invocation:
|
||||
# `gcloud builds submit --config=cloudbuild.yaml --substitutions=_ZONE=us-central1-b,_CLUSTER=demo-app-staging .`
|
||||
|
||||
steps:
|
||||
- id: 'Write git commit to frontend'
|
||||
name: 'ubuntu'
|
||||
entrypoint: 'bash'
|
||||
args:
|
||||
- '-c'
|
||||
- |
|
||||
tools/insert_git_commit_link.sh
|
||||
env:
|
||||
- "COMMIT_SHA=$COMMIT_SHA"
|
||||
- "SHORT_SHA=$SHORT_SHA"
|
||||
|
||||
steps:
|
||||
- id: 'Deploy application to cluster'
|
||||
name: 'gcr.io/k8s-skaffold/skaffold:v0.20.0'
|
||||
entrypoint: 'bash'
|
||||
args:
|
||||
- '-c'
|
||||
- >
|
||||
gcloud container clusters get-credentials --zone=$_ZONE $_CLUSTER;
|
||||
skaffold run -f=skaffold.yaml --default-repo=gcr.io/$PROJECT_ID;
|
||||
- |
|
||||
gcloud container clusters get-credentials --zone=$_ZONE $_CLUSTER
|
||||
skaffold run -f=skaffold.yaml --default-repo=gcr.io/$PROJECT_ID
|
||||
|
||||
# Add more power, and more time, for heavy Skaffold build
|
||||
timeout: '3600s'
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<p>
|
||||
© 2018 Google Inc
|
||||
<span class="text-muted">
|
||||
<a href="https://github.com/GoogleCloudPlatform/microservices-demo/">(Source Code)</a>
|
||||
(<a href="https://github.com/GoogleCloudPlatform/microservices-demo/">Source Code</a><!--GIT_COMMIT_LINK-->)
|
||||
</span>
|
||||
</p>
|
||||
<p>
|
||||
|
|
12
tools/insert_git_commit_link.sh
Executable file
12
tools/insert_git_commit_link.sh
Executable file
|
@ -0,0 +1,12 @@
|
|||
# when project is built by Cloud Build from a source trigger, the
|
||||
# commit SHA will be available as an env var
|
||||
|
||||
if [[ "$COMMIT_SHA" && "$SHORT_SHA" ]]; then
|
||||
target="<!--GIT_COMMIT_LINK-->"
|
||||
replace=" [<a href='https://github.com/GoogleCloudPlatform/microservices-demo/commit/${COMMIT_SHA}'\
|
||||
style='font-size:80%'>${SHORT_SHA}</a>]#"
|
||||
|
||||
sed -i'' -e "s^$target^$replace^g" src/frontend/templates/footer.html
|
||||
|
||||
cat src/frontend/templates/footer.html
|
||||
fi
|
Loading…
Add table
Add a link
Reference in a new issue