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 Azure Infrastructure | |
on: | |
workflow_dispatch: | |
inputs: | |
DEPLOY_INIT_MANUALLY: | |
type: boolean | |
description: Initial Deploy of Nginx and Argo | |
push: | |
paths: | |
- "**.tf" | |
pull_request: | |
branches: | |
- main | |
env: | |
ARM_CLIENT_ID: ${{ vars.ARM_CLIENT_ID }} | |
ARM_CLIENT_SECRET: ${{ secrets.ARM_CLIENT_SECRET }} | |
ARM_SUBSCRIPTION_ID: ${{ vars.ARM_SUBSCRIPTION_ID }} | |
ARM_TENANT_ID: ${{ vars.ARM_TENANT_ID }} | |
TF_VAR_clientid: ${{ vars.ARM_CLIENT_ID }} | |
TF_VAR_objectid: ${{ vars.ARM_APP_ID_azurekeyvaultsecretsprovider_aks_subneterdev }} | |
TF_VAR_VITE_API_SERVER_URL: ${{ vars.VITE_API_SERVER_URL }} | |
TF_VAR_BACKEND_URL: ${{ vars.BACKEND_URL }} | |
TF_VAR_FRONTEND_URL: ${{ vars.FRONTEND_URL }} | |
TF_VAR_DB_HOST: ${{ vars.DB_HOST }} | |
TF_VAR_DB_NAME: ${{ vars.DB_NAME }} | |
TF_VAR_DB_PORT: ${{ vars.DB_PORT }} | |
TF_VAR_DB_USER: ${{ vars.DB_USER }} | |
TF_VAR_DB_PASSWORD: ${{ vars.DB_PASSWORD }} | |
jobs: | |
deploy-terraform: | |
name: Deploy Azure Infrastructure with Terraform | |
runs-on: ubuntu-latest | |
environment: development | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Install Terraform | |
uses: hashicorp/setup-terraform@v3 | |
with: | |
terraform_version: latest | |
- name: Install TFlint | |
uses: terraform-linters/setup-tflint@v4 | |
with: | |
tflint_version: latest | |
- name: Login to Azure | |
uses: azure/login@v1 | |
with: | |
creds: ${{ secrets.AZURE_CREDENTIALS }} | |
- name: Enable Storage Account Access | |
run: | | |
az storage account update --subscription ${{env.ARM_SUBSCRIPTION_ID}} --name ${{vars.SA_BACKEND_NAME}} --public-network-access Enabled | |
- name: Terraform Init | |
run: terraform init | |
working-directory: ./infrastructure/terraform | |
- name: Terraform Validate | |
run: terraform validate | |
working-directory: ./infrastructure/terraform | |
- name: Terraform Format | |
run: terraform fmt -check -recursive | |
working-directory: ./infrastructure/terraform | |
- name: Terraform Plan | |
id: tf-plan | |
run: terraform plan -out plan.infra | |
working-directory: ./infrastructure/terraform | |
- name: Publish Terraform Plan | |
uses: actions/upload-artifact@v3 | |
with: | |
name: tfplan | |
path: ./infrastructure/terraform/plan.infra | |
- name: Download Terraform Plan | |
uses: actions/download-artifact@v3 | |
with: | |
name: tfplan | |
- name: Terraform Apply | |
run: terraform apply -auto-approve plan.infra | |
working-directory: ./infrastructure/terraform | |
- name: Disable Storage Account Access | |
run: | | |
az storage account update --subscription ${{env.ARM_SUBSCRIPTION_ID}} --name ${{vars.SA_BACKEND_NAME}} --public-network-access Disabled |