Skip to content

Instantly share code, notes, and snippets.

@k1ng440
Forked from adilsoncarvalho/bitbucket-pipelines.yml
Created September 13, 2018 01:03
Show Gist options
  • Save k1ng440/e49dbbe6568a9bcb4b6680b97a55cbf2 to your computer and use it in GitHub Desktop.
Save k1ng440/e49dbbe6568a9bcb4b6680b97a55cbf2 to your computer and use it in GitHub Desktop.
Bitbucket Pipelines deployment to a Google Container Engine configuration
options:
docker: true
pipelines:
branches:
master:
- step:
image: google/cloud-sdk:latest
name: Deploy to production
deployment: production
caches:
- docker
script:
# SETUP
- export IMAGE_NAME=us.gcr.io/$GCLOUD_PROJECT/$BITBUCKET_REPO_SLUG:$BITBUCKET_COMMIT
- export ENVIRONMENT=production
- echo $GCLOUD_API_KEYFILE | base64 -d > ~/.gcloud-api-key.json
- gcloud auth activate-service-account --key-file ~/.gcloud-api-key.json
- gcloud config set project $GCLOUD_PROJECT
- gcloud container clusters get-credentials $GCLOUD_CLUSTER --zone=$GCLOUD_ZONE --project $GCLOUD_PROJECT
- gcloud auth configure-docker --quiet
# BUILD IMAGE
- docker build . -t $IMAGE_NAME
# PUBLISH IMAGE
- docker push $IMAGE_NAME
# DEPLOYMENT
- kubectl set image deployment $BITBUCKET_REPO_SLUG-$ENVIRONMENT $BITBUCKET_REPO_SLUG=$IMAGE_NAME --record --namespace=$K8S_NAMESPACE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment