Skip to content

Instantly share code, notes, and snippets.

@sohiniroych
Created February 17, 2021 21:42
Show Gist options
  • Select an option

  • Save sohiniroych/f9775a564a9b80f48efcab6e99d35313 to your computer and use it in GitHub Desktop.

Select an option

Save sohiniroych/f9775a564a9b80f48efcab6e99d35313 to your computer and use it in GitHub Desktop.
YAML file
steps:
# pull the container image if it is already built
- name: 'gcr.io/cloud-builders/docker'
entrypoint: 'bash'
args:
- '-c'
- 'docker pull gcr.io/$PROJECT_ID/appcicd:latest || exit 0'
# build the container image
- name: 'gcr.io/cloud-builders/docker'
args:
- 'build'
- '-t'
- 'gcr.io/$PROJECT_ID/appcicd:latest'
- '-t'
- 'gcr.io/$PROJECT_ID/appcicd:$COMMIT_SHA'
- '--cache-from'
- 'gcr.io/$PROJECT_ID/appcicd:latest'
- '.'
# push the container image to Container Registry with all tags
- name: 'gcr.io/cloud-builders/docker'
args:
- 'push'
- 'gcr.io/$PROJECT_ID/appcicd'
# deploy container image to Cloud Run
- name: 'gcr.io/cloud-builders/gcloud'
args:
- 'run'
- 'deploy'
- 'flaskappml'
- '--image'
- 'gcr.io/$PROJECT_ID/appcicd:latest'
- '--region'
- 'us-central1'
- '--platform'
- 'managed'
- '--allow-unauthenticated'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment