Deploy new image version #9
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy new image version | |
on: | |
workflow_dispatch: | |
env: | |
TAG: ${{ github.run_number}} | |
GKE_CLUSTER: services-prod-1 | |
GKE_ZONE: europe-west2-b | |
jobs: | |
build-image-and-push: | |
name: Build image and push to ghcr.io | |
runs-on: ubuntu-latest | |
environment: production | |
steps: | |
- name: Check out the repo | |
uses: actions/checkout@v3.3.0 | |
- name: Import Secrets | |
id: import-secrets | |
uses: hashicorp/vault-action@v2 | |
with: | |
url: https://vault.kavehome.com/ | |
method: github | |
githubToken: ${{ secrets.ITKAVEHOME_VAULT_TOKEN_READ }} | |
caCertificate: ${{ secrets.ITKAVEHOME_VAULT_KEYCHAIN_CERTIFICATE }} | |
secrets: | | |
k8s/kv/kave-tech-services/data/generic-utils GOOGLE_APPLICATION_CREDENTIALS_DEPLOY; | |
- name: Set lower case repository name | |
id: prepare-outputs | |
run: | | |
echo "IMAGE_REPOSITORY_LOWERCASE=$(printf ${{ github.repository }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV | |
- name: Log in to GitHub Docker Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ github.token }} | |
- name: Set up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Build&Push App container image | |
uses: docker/build-push-action@v4 | |
with: | |
file: Dockerfile | |
builder: ${{ steps.buildx.outputs.name }} | |
push: true | |
tags: | | |
ghcr.io/${{ env.IMAGE_REPOSITORY_LOWERCASE }}:${{ env.TAG }} | |
cache-from: type=registry,ref=ghcr.io/${{ env.IMAGE_REPOSITORY_LOWERCASE }}:build-cache | |
cache-to: type=registry,ref=ghcr.io/${{ env.IMAGE_REPOSITORY_LOWERCASE }}:build-cache | |
- name: Install Helm | |
uses: azure/setup-helm@v3 | |
# Setup gcloud CLI | |
- id: auth | |
uses: google-github-actions/auth@v1 | |
with: | |
credentials_json: ${{ env.GOOGLE_APPLICATION_CREDENTIALS_DEPLOY }} | |
- name: Set up Cloud SDK | |
uses: google-github-actions/setup-gcloud@v1 | |
# Get the GKE credentials so we can deploy to the cluster | |
- run: |- | |
gcloud container clusters get-credentials "$GKE_CLUSTER" --zone "$GKE_ZONE" | |
- run: |- | |
gcloud components install gke-gcloud-auth-plugin | |
- name: Deploy to GKE using Helm | |
run: |- | |
helm upgrade url-shortener ./helm/url-shortener --namespace url-shortener --reuse-values --set kutt.image.tag="${{ env.TAG }}" |