-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created aks deploy workflow for the project
WHY: The aks deploy workflow is necessary for automatic deployment HOW: The aks deploy workflow is embedded in the existing paas workflow
- Loading branch information
Tope Emmanuel
committed
Sep 18, 2023
1 parent
eb65f70
commit d14ab00
Showing
2 changed files
with
143 additions
and
43 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
name: Deploy to AKS | ||
description: deploys application | ||
inputs: | ||
environment: | ||
description: Environment to deploy to | ||
required: true | ||
sha: | ||
description: Commit sha to be deployed | ||
required: true | ||
azure-credentials: | ||
description: Credentials for azure | ||
required: true | ||
pr: | ||
description: Pull Request Reference | ||
required: false | ||
|
||
outputs: | ||
deploy-url: | ||
value: ${{ steps.set_env_var.outputs.deploy_url }} | ||
runs: | ||
using: composite | ||
steps: | ||
- name: Set Environment variables | ||
id: set_env_var | ||
shell: bash | ||
run: | | ||
echo ls terraform | ||
envtolower=`echo "${{ inputs.environment }} " | awk '{ print tolower($1) }'` | ||
tf_vars_file=terraform/aks/config/$envtolower.tfvars.json | ||
echo " tf_vars_file is $tf_vars_file" | ||
terraform_version=$(awk '/{/{f=/^terraform/;next}f' terraform/aks/terraform.tf | grep -o [0-9\.]*) | ||
echo "cluster=$(jq -r '.cluster' ${tf_vars_file})" >> $GITHUB_ENV | ||
echo "aks_app_environment=$(jq -r '.environment' ${tf_vars_file})" >> $GITHUB_ENV | ||
echo "TERRAFORM_VERSION=$terraform_version" >> $GITHUB_ENV | ||
echo "namespace=$(jq -r '.namespace' ${tf_vars_file})" >> $GITHUB_ENV | ||
if [[ $cluster == 'production' ]]; then | ||
echo "deploy_url=https://getintoteachingapi-${{ env.aks_app_environment }}.teacherservices.cloud" >> $GITHUB_OUTPUT | ||
else | ||
echo "deploy_url=https://getintoteachingapi-${{ env.aks_app_environment }}.${cluster}.teacherservices.cloud" >> $GITHUB_OUTPUT | ||
fi | ||
- name: Use Terraform ${{ env.TERRAFORM_VERSION }} | ||
uses: hashicorp/setup-terraform@v2 | ||
with: | ||
terraform_version: ${{ env.TERRAFORM_VERSION }} | ||
|
||
- uses: DFE-Digital/github-actions/set-arm-environment-variables@master | ||
with: | ||
azure-credentials: ${{ inputs.azure-credentials }} | ||
|
||
- name: Print Sha | ||
id: print-sha-environment | ||
shell: bash | ||
run: | | ||
echo "${{ inputs.sha }}" | ||
echo "the passed in environment is ${{ inputs.environment }}" | ||
echo terraform version | ||
- name: Terraform init, plan & apply | ||
if: ${{ inputs.environment }} == "Review" | ||
shell: bash | ||
run: | | ||
envtolower=`echo "${{ inputs.environment }} " | awk '{ print tolower($1) }'` | ||
envval="${envtolower}_aks" | ||
echo "envval is ${envval}" | ||
echo "running in Review" | ||
make ci ${envval} terraform-plan-aks PR_NUMBER=${{ inputs.pr }} | ||
env: | ||
IMAGE_TAG: ${{ inputs.sha }} | ||
|
||
|
||
- name: Terraform init, plan & apply | ||
if: ${{ inputs.environment }} != "Review" | ||
shell: bash | ||
run: | | ||
envtolower=`echo "${{ inputs.environment }} " | awk '{ print tolower($1) }'` | ||
envval="${envtolower}_aks" | ||
echo "envval is ${envval}" | ||
echo "not running in Review" | ||
make ci ${envval} terraform-plan-aks | ||
env: | ||
IMAGE_TAG: ${{ inputs.sha }} |
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