diff --git a/cloudbuild.yaml b/cloudbuild.yaml index 2d031ce..8b76515 100644 --- a/cloudbuild.yaml +++ b/cloudbuild.yaml @@ -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' diff --git a/src/frontend/templates/footer.html b/src/frontend/templates/footer.html index 0ca31e1..5519847 100644 --- a/src/frontend/templates/footer.html +++ b/src/frontend/templates/footer.html @@ -4,7 +4,7 @@

© 2018 Google Inc - (Source Code) + (Source Code)

diff --git a/tools/insert_git_commit_link.sh b/tools/insert_git_commit_link.sh new file mode 100755 index 0000000..00f84ae --- /dev/null +++ b/tools/insert_git_commit_link.sh @@ -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="" + replace=" [${SHORT_SHA}]#" + + sed -i'' -e "s^$target^$replace^g" src/frontend/templates/footer.html + + cat src/frontend/templates/footer.html +fi \ No newline at end of file