Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
125 changes: 62 additions & 63 deletions .github/workflows/dev.yaml
Original file line number Diff line number Diff line change
@@ -1,79 +1,78 @@
name: Build, Tag, Publish and Deploy to GKE

on:
push:
branches:
- dev
push:
branches:
- dev

# Environment variables available to all jobs and steps in this workflow
env:
GITHUB_SHA: ${{ github.sha }}
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
DOCKER_ORGANIZATION: ${{ secrets.DOCKER_ORGANIZATION }}
PROJECT_ID: ${{ secrets.GKE_PROJECT }}
GKE_CLUSTER: wisp-prod
GKE_ZONE: northamerica-northeast1-c
IMAGE: wisp-users
GITHUB_SHA: ${{ github.sha }}
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
DOCKER_ORGANIZATION: ${{ secrets.DOCKER_ORGANIZATION }}
PROJECT_ID: ${{ secrets.GKE_PROJECT }}
GKE_CLUSTER: ${{ secrets.GKE_CLUSTER }}
GKE_ZONE: northamerica-northeast1-c
IMAGE: wisp-users

jobs:
setup-build-tag-publish-deploy:
name: Setup, Build, Tag, Publish, and Deploy
runs-on: ubuntu-latest
steps:
setup-build-tag-publish-deploy:
name: Setup, Build, Tag, Publish, and Deploy
runs-on: ubuntu-latest
steps:
# Checkout Commit
- name: Checkout
uses: actions/checkout@v2

# Checkout Commit
- name: Checkout
uses: actions/checkout@v2
# Setup gcloud CLI
- uses: GoogleCloudPlatform/github-actions/setup-gcloud@master
with:
service_account_key: ${{ secrets.GKE_SA_KEY }}
project_id: ${{ secrets.GKE_PROJECT }}

# Setup gcloud CLI
- uses: GoogleCloudPlatform/github-actions/setup-gcloud@master
with:
service_account_key: ${{ secrets.GKE_SA_KEY }}
project_id: ${{ secrets.GKE_PROJECT }}
# Configure Docker to use the gcloud command-line tool as a credential
# helper for authentication
- run: |-
gcloud --quiet auth configure-docker
- run: |-
gcloud container clusters get-credentials "$GKE_CLUSTER" --zone "$GKE_ZONE"

# Configure Docker to use the gcloud command-line tool as a credential
# helper for authentication
- run: |-
gcloud --quiet auth configure-docker
- run: |-
gcloud container clusters get-credentials "$GKE_CLUSTER" --zone "$GKE_ZONE"
# Build the Docker image
- name: Build
run: |
docker build -t "$DOCKER_ORGANIZATION"/"$IMAGE":dev-$(echo ${GITHUB_SHA} | cut -c1-8) .

# Build the Docker image
- name: Build
run: |
docker build -t "$DOCKER_ORGANIZATION"/"$IMAGE":dev-$(echo ${GITHUB_SHA} | cut -c1-8) .

# Tag the Docker image
- name: Tag
run: |
docker tag "$DOCKER_ORGANIZATION"/"$IMAGE":dev-$(echo ${GITHUB_SHA} | cut -c1-8) "$DOCKER_ORGANIZATION"/"$IMAGE":dev-latest
# Tag the Docker image
- name: Tag
run: |
docker tag "$DOCKER_ORGANIZATION"/"$IMAGE":dev-$(echo ${GITHUB_SHA} | cut -c1-8) "$DOCKER_ORGANIZATION"/"$IMAGE":dev-latest

# Push the Docker image to Dockerhub
- name: Publish
run: |
docker login -u=$DOCKER_USERNAME -p=$DOCKER_PASSWORD
docker push $DOCKER_ORGANIZATION/$IMAGE
env:
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
# Push the Docker image to Dockerhub
- name: Publish
run: |
docker login -u=$DOCKER_USERNAME -p=$DOCKER_PASSWORD
docker push $DOCKER_ORGANIZATION/$IMAGE
env:
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}

# Install helm for use in pipeline
- name: Install helm
run: |
wget -q -O get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3
chmod 700 get_helm.sh
./get_helm.sh
# Install helm for use in pipeline
- name: Install helm
run: |
wget -q -O get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3
chmod 700 get_helm.sh
./get_helm.sh

# Deploy to GKE cluster using helm
- name: Deploy
run: |-
helm upgrade --atomic --install dev-users ./chart/wisp-users/ --namespace dev --set image.tag=dev-$(echo ${GITHUB_SHA} | cut -c1-8)
# Deploy to GKE cluster using helm
- name: Deploy
run: |-
helm upgrade --atomic --install dev-users ./chart/wisp-users/ --namespace dev --set image.tag=dev-$(echo ${GITHUB_SHA} | cut -c1-8)

e2e:
needs: setup-build-tag-publish-deploy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: wget https://raw.githubusercontent.com/Compete-McGill/wisp/master/e2e/docker-compose.yaml -O docker-compose.e2e.yaml
- run: docker login -u=$DOCKER_USERNAME -p=$DOCKER_PASSWORD
- run: docker-compose -f docker-compose.e2e.yaml up --abort-on-container-exit
e2e:
needs: setup-build-tag-publish-deploy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: wget https://raw.githubusercontent.com/Compete-McGill/wisp/master/e2e/docker-compose.yaml -O docker-compose.e2e.yaml
- run: docker login -u=$DOCKER_USERNAME -p=$DOCKER_PASSWORD
- run: docker-compose -f docker-compose.e2e.yaml up --abort-on-container-exit
109 changes: 54 additions & 55 deletions .github/workflows/prod.yaml
Original file line number Diff line number Diff line change
@@ -1,70 +1,69 @@
name: Build, Tag, and Publish to DockerHub

on:
push:
branches:
- master
push:
branches:
- master

# Environment variables available to all jobs and steps in this workflow
env:
GITHUB_SHA: ${{ github.sha }}
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
DOCKER_ORGANIZATION: ${{ secrets.DOCKER_ORGANIZATION }}
PROJECT_ID: ${{ secrets.GKE_PROJECT }}
GKE_CLUSTER: wisp-prod
GKE_ZONE: northamerica-northeast1-c
IMAGE: wisp-users
GITHUB_SHA: ${{ github.sha }}
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
DOCKER_ORGANIZATION: ${{ secrets.DOCKER_ORGANIZATION }}
PROJECT_ID: ${{ secrets.GKE_PROJECT }}
GKE_CLUSTER: ${{ secrets.GKE_CLUSTER }}
GKE_ZONE: northamerica-northeast1-c
IMAGE: wisp-users

jobs:
setup-build-tag-publish-deploy:
name: Setup, Build, Tag, and Publish
runs-on: ubuntu-latest
steps:
setup-build-tag-publish-deploy:
name: Setup, Build, Tag, and Publish
runs-on: ubuntu-latest
steps:
# Checkout Commit
- name: Checkout
uses: actions/checkout@v2

# Checkout Commit
- name: Checkout
uses: actions/checkout@v2
# Setup gcloud CLI
- uses: GoogleCloudPlatform/github-actions/setup-gcloud@master
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: Why don't we have a key-value pair for name on the Setup gCloud step?

with:
service_account_key: ${{ secrets.GKE_SA_KEY }}
project_id: ${{ secrets.GKE_PROJECT }}

# Setup gcloud CLI
- uses: GoogleCloudPlatform/github-actions/setup-gcloud@master
with:
service_account_key: ${{ secrets.GKE_SA_KEY }}
project_id: ${{ secrets.GKE_PROJECT }}
# Configure Docker to use the gcloud command-line tool as a credential
# helper for authentication
- run: |-
gcloud --quiet auth configure-docker
- run: |-
gcloud container clusters get-credentials "$GKE_CLUSTER" --zone "$GKE_ZONE"

# Configure Docker to use the gcloud command-line tool as a credential
# helper for authentication
- run: |-
gcloud --quiet auth configure-docker
- run: |-
gcloud container clusters get-credentials "$GKE_CLUSTER" --zone "$GKE_ZONE"
# Build the Docker image
- name: Build
run: |
docker build -t "$DOCKER_ORGANIZATION"/"$IMAGE":$(echo ${GITHUB_SHA} | cut -c1-8) .

# Build the Docker image
- name: Build
run: |
docker build -t "$DOCKER_ORGANIZATION"/"$IMAGE":$(echo ${GITHUB_SHA} | cut -c1-8) .

# Tag the Docker image
- name: Tag
run: |
docker tag "$DOCKER_ORGANIZATION"/"$IMAGE":$(echo ${GITHUB_SHA} | cut -c1-8) "$DOCKER_ORGANIZATION"/"$IMAGE":latest
# Tag the Docker image
- name: Tag
run: |
docker tag "$DOCKER_ORGANIZATION"/"$IMAGE":$(echo ${GITHUB_SHA} | cut -c1-8) "$DOCKER_ORGANIZATION"/"$IMAGE":latest

# Push the Docker image to Dockerhub
- name: Publish
run: |
docker login -u=$DOCKER_USERNAME -p=$DOCKER_PASSWORD
docker push $DOCKER_ORGANIZATION/$IMAGE
env:
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
# Push the Docker image to Dockerhub
- name: Publish
run: |
docker login -u=$DOCKER_USERNAME -p=$DOCKER_PASSWORD
docker push $DOCKER_ORGANIZATION/$IMAGE
env:
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}

# Install helm for use in pipeline
- name: Install helm
run: |
wget -q -O get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3
chmod 700 get_helm.sh
./get_helm.sh
# Install helm for use in pipeline
- name: Install helm
run: |
wget -q -O get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3
chmod 700 get_helm.sh
./get_helm.sh

# Deploy to GKE cluster using helm
- name: Deploy
run: |-
helm upgrade --atomic --install prod-users ./chart/wisp-users/ --namespace prod --set image.tag=$(echo ${GITHUB_SHA} | cut -c1-8) --set replicaCount=2
# Deploy to GKE cluster using helm
- name: Deploy
run: |-
helm upgrade --atomic --install prod-users ./chart/wisp-users/ --namespace prod --set image.tag=$(echo ${GITHUB_SHA} | cut -c1-8) --set replicaCount=2