sudo: required services: - docker language: node_js node_js: - "node" env: global: - IMAGE_NAME=acme-corp/cake-service - REGISTRY_USER=myrobot # Ensure the install happens without prompts - CLOUDSDK_CORE_DISABLE_PROMPTS=1 # REGISTRY_PASS=... - secret: "" before_script: - version="$(awk '$2 == "CAKE_SERVICE_VERSION" { print $3; exit }' Dockerfile)" - docker pull "$IMAGE_NAME" || true script: - docker build --pull --cache-from "$IMAGE_NAME" --tag "$IMAGE_NAME" . after_script: - docker images before_deploy: - docker login -u "$REGISTRY_USER" -p "$REGISTRY_PASS" - docker tag "$IMAGE_NAME" "${IMAGE_NAME}:latest" - docker tag "$IMAGE_NAME" "${IMAGE_NAME}:${version}" deploy: provider: script script: docker push "${IMAGE_NAME}:latest" && docker push "${IMAGE_NAME}:${version}" on: branch: master