Skip to content

Commit

Permalink
Merge pull request #7 from heathen1878/deploy_to_sandbox
Browse files Browse the repository at this point in the history
Added deployment to sandbox
  • Loading branch information
heathen1878 authored Sep 11, 2024
2 parents ae3271e + f99aa65 commit 9ebdb65
Show file tree
Hide file tree
Showing 4 changed files with 398 additions and 154 deletions.
54 changes: 43 additions & 11 deletions .github/workflows/deploy_infra.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,69 @@ name: Deploy Infra
on:
push:
branches: master
paths:
- '**.tf'

jobs:
deploy_infra:
runs-on: ubuntu-latest
name: Deploy Infrastructure using Terraform
steps:
- name: checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v3

# - name: auth
# uses: azure/#@v2
# with:
# creds: ${{ secrets.AZURE_CREDENTIALS }}
# enable-AzPSSession: true
- name: auth
uses: azure/#@v2
with:
creds: '{"clientId": "${{ secrets.ARM_CLIENT_ID }}", "clientSecret": "${{ secrets.ARM_CLIENT_SECRET }}", "tenantId": "${{ secrets.ARM_TENANT_ID }}", "subscriptionId": "${{ vars.ARM_SUBSCRIPTION_ID }}"}'

- name: get runner ip
id: runner_ip
run: |
IP_ADDR=$(curl -s https://ifconfig.me/ip)
echo "IPADDR=$IP_ADDR" >> $GITHUB_OUTPUT
- name: modify state storage acl
run: |
az storage account network-rule add --account-name ${{ vars.STATE_STORAGE_ACCOUNT }} --ip-address ${{ steps.runner_ip.outputs.IPADDR }} --subscription ${{ vars.ARM_SUBSCRIPTION_ID }} > /dev/null 2>&1
echo "Pausing for 60 seconds to ensure the ACL has been set..."
sleep 60
- name: install terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: ${{ vars.TERRAFORM_VERSION }}

- name: terraform init and plan
- name: terraform init
id: init
run: |
cd ./iac/frontend_app_service
# export variables as environment variables
export ARM_CLIENT_ID=${{ secrets.ARM_CLIENT_ID }}
export ARM_CLIENT_SECRET=${{ secrets.ARM_CLIENT_SECRET }}
export ARM_TENANT_ID=${{ secrets.ARM_TENANT_ID }}
export ARM_SUBSCRIPTION_ID=${{ vars.ARM_SUBSCRIPTION_ID }}
export ARM_USE_AZUREAD=true
terraform init \
-upgrade \
-input=false \
-backend-config="storage_account_name=${{ vars.STATE_STORAGE_ACCOUNT }}" \
-backend-config="container_name=${{ vars.STATE_STORAGE_CONTAINER }}" \
-backend-config="key=${{ vars.STATE_FILE_NAME }}"
- name: terraform apply
id: apply
run: |
# export variables as environment variables
export ARM_CLIENT_ID=${{ secrets.ARM_CLIENT_ID }}
export ARM_CLIENT_SECRET=${{ secrets.ARM_CLIENT_SECRET }}
export ARM_TENANT_ID=${{ secrets.ARM_TENANT_ID }}
export ARM_SUBSCRIPTION_ID=${{ vars.ARM_SUBSCRIPTION_ID }}
export ARM_USE_AZUREAD=true
terraform apply --auto-approve
terraform init -upgrade -input=false
terraform plan
- name: modify state storage acl - clean up
if: always()
run: |
az storage account network-rule remove --account-name ${{ vars.STATE_STORAGE_ACCOUNT }} --ip-address ${{ steps.runner_ip.outputs.IPADDR }} --subscription ${{ vars.ARM_SUBSCRIPTION_ID }} > /dev/null 2>&1
141 changes: 0 additions & 141 deletions .github/workflows/plan_infra.yaml

This file was deleted.

Loading

0 comments on commit 9ebdb65

Please # to comment.