GHA Self-hosted Infra - Azure #196
This file contains hidden or 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: GHA Self-hosted Infra - Azure | |
run-name: GHA Self-hosted Infra - Azure | |
on: | |
push: | |
paths: | |
- create-azure-infra/** | |
workflow_dispatch: | |
inputs: | |
confirm: | |
description: "Type 'yes' to confirm Terraform destroy" | |
required: false | |
permissions: | |
id-token: write | |
contents: read | |
jobs: | |
deploy-azure-infra: | |
runs-on: ubuntu-latest | |
environment: dev | |
env: | |
ARM_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }} | |
ARM_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }} | |
ARM_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }} | |
ARM_USE_OIDC: true | |
TF_VAR_GITHUB_APP_PEM_FILE: ${{ secrets.TF_VAR_GITHUB_APP_PEM_FILE }} | |
TF_VAR_GITHUB_APP_CLIENTID: ${{ secrets.TF_VAR_GITHUB_APP_CLIENTID }} | |
TF_VAR_GITHUB_APP_ID: ${{ secrets.TF_VAR_GITHUB_APP_ID }} | |
TF_VAR_GITHUB_APP_INSTALLATION_ID: ${{ secrets.TF_VAR_GITHUB_APP_INSTALLATION_ID }} | |
defaults: | |
run: | |
shell: bash | |
working-directory: create-azure-infra | |
outputs: | |
terraform-apply-success: ${{ steps.terraform-apply.outcome == 'success' }} | |
steps: | |
- name: 'Checkout Azure Infra' | |
uses: actions/checkout@v4 | |
with: | |
sparse-checkout: | |
create-azure-infra | |
- name: Setup Terraform | |
uses: hashicorp/setup-terraform@v3 | |
- name: Terraform init | |
run : terraform init -backend-config="dev-backend.config" | |
- name: Terraform Plan | |
if: ${{ github.event_name == 'push' || github.event.inputs.confirm != 'yes' }} | |
run: terraform plan -var-file="dev.tfvars" -out="tfplan.out" | |
- name: Terraform Apply | |
id: terraform-apply | |
if: ${{ github.event_name == 'push' || github.event.inputs.confirm != 'yes' }} | |
run: terraform apply -auto-approve -lock=false "tfplan.out" | |
- name: Terraform destroy plan | |
if: github.event.inputs.confirm == 'yes' | |
run: terraform plan -destroy -out=destroyplan -var-file="dev.tfvars" | |
- name: Terraform destroy infra | |
if: github.event.inputs.confirm == 'yes' | |
run: terraform apply -destroy "destroyplan" | |
# deploy-receiver-fn-caller: | |
# needs: "deploy-azure-infra" | |
# if: ${{ needs.deploy-azure-infra.outputs.terraform-apply-success == 'true' }} | |
# uses: ./.github/workflows/deploy_receiver_function.yml | |
# secrets: inherit | |
# deploy-controller-fn-caller: | |
# needs: "deploy-azure-infra" | |
# if: ${{ needs.deploy-azure-infra.outputs.terraform-apply-success == 'true' }} | |
# uses: ./.github/workflows/build_deploy_controller_function.yml | |
# secrets: inherit | |
# deploy-runner-images: | |
# needs: "deploy-azure-infra" | |
# if: ${{ needs.deploy-azure-infra.outputs.terraform-apply-success == 'true' }} | |
# uses: ./.github/workflows/build_deploy_images.yml | |
# secrets: inherit |