Skip to content

Instantly share code, notes, and snippets.

@theguuholi
Last active April 6, 2021 13:09
Show Gist options
  • Save theguuholi/52308787fb52701b66ec52a36958980e to your computer and use it in GitHub Desktop.
Save theguuholi/52308787fb52701b66ec52a36958980e to your computer and use it in GitHub Desktop.
name: Deploy GKE
on:
push:
branches:
- main
env:
PROJECT_ID: ${{ secrets.GKE_PROJECT }}
GKE_CLUSTER: ${{ secrets.GKE_CLUSTER }}
GKE_REGION: ${{ secrets.GKE_REGION }}
IMAGE: ${{ secrets.APP }}
HELM_PROJECT: ${{ secrets.HELM_PROJECT }}
NAMESPACE: ${{ secrets.NAMESPACE }}
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: GoogleCloudPlatform/github-actions/setup-gcloud@master
with:
version: '290.0.1'
service_account_key: ${{ secrets.GKE_SA_KEY }}
project_id: ${{ secrets.PROJECT_ID }}
- run: |-
gcloud --quiet auth configure-docker
- run: |-
gcloud container clusters get-credentials "$GKE_CLUSTER" --region "$GKE_REGION" --project "$PROJECT_ID"
- name: Build docker IMAGE
run: |-
docker pull "gcr.io/$PROJECT_ID/$IMAGE:$GITHUB_SHA" > /dev/null || docker build -t "gcr.io/$PROJECT_ID/$IMAGE:$GITHUB_SHA" .
- name: Push docker image
run: |-
docker push "gcr.io/$PROJECT_ID/$IMAGE:$GITHUB_SHA"
- name: Deploy Helm Chart
working-directory: "./charts/${{ env.IMAGE }}"
run: |-
pwd
helm dependency update
helm \
-n "$NAMESPACE" \
upgrade "$HELM_PROJECT" \
./ \
--wait \
--reuse-values \
--set image.repository="gcr.io/$PROJECT_ID/$IMAGE",image.tag="$GITHUB_SHA"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment