PROD Cluster deployment on main #23
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: PROD Cluster deployment | |
run-name: PROD Cluster deployment on ${{ github.ref_name }} | |
on: | |
workflow_dispatch: | |
inputs: | |
debug: | |
description: "Whether print debug info during the deployment" | |
required: true | |
default: "No" | |
type: choice | |
options: | |
- "Yes" | |
- "No" | |
env: | |
CLUSTER_NAME: search-data-gov-au-new | |
CLUSTER_ZONE: australia-southeast1 | |
GCP_PROJECT: terriajs | |
RELEASE_NAME: magda | |
DEPLOY_NAMESPACE: dga-prod | |
GCP_SRV_ACC_NAME: [email protected] | |
GCLOUD_KEY: ${{ secrets.GCLOUD_KEY }} | |
DEPLOY_CHART: "./chart" | |
DEPLOY_CONFIG_FILE: "./config.yaml" | |
jobs: | |
prod-cluster-deployment: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install gke-gcloud-auth-plugin | |
run: | | |
REPO_URL="https://packages.cloud.google.com/apt" | |
echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] $REPO_URL cloud-sdk main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list | |
sudo curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key --keyring /usr/share/keyrings/cloud.google.gpg add - | |
sudo apt-get update -y | |
sudo apt-get install -y google-cloud-sdk-gke-gcloud-auth-plugin | |
- name: Login to GAR & Cluster | |
run: | | |
echo $GCLOUD_KEY > ./gcloud-key.json | |
gcloud auth activate-service-account ${GCP_SRV_ACC_NAME} --key-file=./gcloud-key.json | |
gcloud auth configure-docker australia-southeast1-docker.pkg.dev | |
gcloud container clusters get-credentials \ | |
${CLUSTER_NAME} \ | |
--zone ${CLUSTER_ZONE} \ | |
--project ${GCP_PROJECT} | |
- name: Download Helm Chart Dependencies | |
run: | | |
helm dep up ./chart | |
- name: Deployment | |
env: | |
DEPLOYMENT_DEBUG: ${{ inputs.debug }} | |
run: | | |
echo "Deployment Debug Switch: $DEPLOYMENT_DEBUG" | |
if [[ "$DEPLOYMENT_DEBUG" == "Yes" ]]; then | |
export HELM_DEPLOYMENT_SWITCH_DEBUG="--debug" | |
else | |
export HELM_DEPLOYMENT_SWITCH_DEBUG="" | |
fi | |
helm upgrade ${HELM_DEPLOYMENT_SWITCH_DEBUG} \ | |
--install \ | |
--namespace ${DEPLOY_NAMESPACE} \ | |
--timeout 1200s\ | |
${RELEASE_NAME} \ | |
${DEPLOY_CHART} \ | |
-f ${DEPLOY_CONFIG_FILE} | |