Skip to content

Instantly share code, notes, and snippets.

@albertorm95
Created June 4, 2020 03:43
Show Gist options
  • Save albertorm95/d384ba80ec9e03499f8a12eeafd34a11 to your computer and use it in GitHub Desktop.
Save albertorm95/d384ba80ec9e03499f8a12eeafd34a11 to your computer and use it in GitHub Desktop.
Deploy Prod Environment
name: Deploy PROD - Release created
on:
release:
types:
- created
paths-ignore:
- 'README.md'
# Environment variables available to all jobs and steps in this workflow
env:
PROJECT: medium
GKE_ZONE: us-west2
GKE_CLUSTER: meidum-prod
NAMESPACE: prod
ENV: prod
GITHUB_SHA: ${{ github.sha }}
REGISTRY_HOSTNAME: gcr.io
SERVICE_NAME: mediumpod
jobs:
release_workflow:
name: Deploy PROD - Release created
runs-on: ubuntu-18.04
steps:
# Clone the repository
- name: Checkout
uses: actions/checkout@v2
# Setup Admin gcloud CLI
- name: Configure Admin Google Cloud Account
uses: GoogleCloudPlatform/github-actions/setup-gcloud@master
with:
version: '270.0.0'
service_account_key: ${{ secrets.REGISTRY_SA }}
# Configure docker to use the gcloud command-line tool as a credential helper
- name: Configure Docker
run: |
gcloud auth configure-docker
# Pull reference Docker image
- name: Pull Image
run: |
docker pull $REGISTRY_HOSTNAME/$ADMIN_PROJECT/$SERVICE_NAME:${GITHUB_REF##*/}
# Setup Env GKE
- name: Configure Cluster
run: gcloud container clusters get-credentials $GKE_CLUSTER --zone $GKE_ZONE --project $PROJECT
# Configuring deploy files
- name: Configuring Deployment
run: |
sed -i \
-e 's#newTag: .*#'"newTag: ${GITHUB_REF##*/}"'#' \
k8s/overlays/$NAMESPACE/kustomization.yml
# Deploy to GKE cluster
- name: Deployment
run: |
kubectl apply -k k8s/overlays/$NAMESPACE
DEPLOYMENT_NAME=`sed -n -e 's/^.*app: //p' k8s/base/kustomization.yml`
kubectl rollout status deployment/$DEPLOYMENT_NAME -n $NAMESPACE --timeout=6m
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment