Terraform #10
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: "Terraform" | |
on: | |
workflow_dispatch: | |
jobs: | |
terraform: | |
name: "Terraform" | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
shell: bash | |
env: | |
ARM_CLIENT_ID: ${{ secrets.ARM_CLIENT_ID }} | |
ARM_CLIENT_SECRET: ${{ secrets.ARM_CLIENT_SECRET }} | |
ARM_SUBSCRIPTION_ID: ${{ secrets.ARM_SUBSCRIPTION_ID }} | |
ARM_TENANT_ID: ${{ secrets.ARM_TENANT_ID }} | |
RESOURCE_GROUP: ${{ secrets.RESOURCE_GROUP }} | |
STORAGE_ACCOUNT: ${{ secrets.STORAGE_ACCOUNT }} | |
CONTAINER_NAME: ${{ secrets.CONTAINER_NAME }} | |
steps: | |
# Checkout the repository to the GitHub Actions runner | |
- name: Checkout | |
uses: actions/checkout@v4.1.1 | |
# Install the preferred version of Terraform CLI | |
- name: Setup Terraform | |
uses: hashicorp/setup-terraform@v2.0.3 | |
with: | |
terraform_version: 1.6.6 | |
# Initialize a new or existing Terraform working directory by creating initial files, loading any remote state, downloading modules, etc. | |
- name: Terraform Init | |
id: init | |
run: terraform init -backend-config="storage_account_name=$STORAGE_ACCOUNT" -backend-config="container_name=$CONTAINER_NAME" -backend-config="resource_group_name=$RESOURCE_GROUP" | |
# Run a terraform plan | |
- name: Terraform Plan | |
id: plan | |
run: terraform plan -no-color | |
# On workflow dispatch build or change infrastructure according to Terraform configuration files | |
- name: Terraform Apply | |
run: terraform apply -auto-approve |