Apply Infrastructure Terraform #93
Workflow file for this run
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: Apply Infrastructure Terraform | |
on: | |
workflow_dispatch: | |
inputs: | |
workspace: | |
description: Choose environment | |
type: choice | |
required: true | |
options: | |
- dev-preview | |
- dev | |
- prod | |
permissions: | |
id-token: write | |
contents: read | |
jobs: | |
terraform: | |
name: 'Terraform' | |
runs-on: ubuntu-latest | |
environment: ${{ github.event.inputs.workspace }} | |
env: | |
ARM_SUBSCRIPTION_ID: ${{ vars.ARM_SUBSCRIPTION_ID }} | |
ARM_CLIENT_ID: ${{ vars.ARM_CLIENT_ID }} | |
ARM_TENANT_ID: ${{ vars.ARM_TENANT_ID }} | |
ARM_USE_OIDC: "true" | |
defaults: | |
run: | |
shell: bash | |
working-directory: ./terraform | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Terraform | |
uses: hashicorp/setup-terraform@v3 | |
with: | |
terraform_version: 1.x | |
- name: Az CLI login using OIDC | |
uses: azure/login@v2 | |
with: | |
client-id: ${{ vars.ARM_CLIENT_ID }} | |
tenant-id: ${{ vars.ARM_TENANT_ID }} | |
subscription-id: ${{ vars.ARM_SUBSCRIPTION_ID }} | |
- name: Terraform init | |
id: init | |
run: terraform init -upgrade | |
- name: Select or create workspace | |
id: select-or-create | |
run: terraform workspace select -or-create ${{ github.event.inputs.workspace }} | |
- name: Terraform apply | |
id: apply | |
run: terraform apply -auto-approve |