Skip to content

Deploy vpc, aks and flux in two environments #34

Deploy vpc, aks and flux in two environments

Deploy vpc, aks and flux in two environments #34

Workflow file for this run

name: Terraform Preview
on:
pull_request:
branches:
- main
jobs:
preview:
name: Plan Terraform changes in changed stacks
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
pull-requests: write
checks: read
steps:
### Check out the code
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
fetch-depth: 0
### Install tooling
- name: Install Terramate
uses: terramate-io/terramate-action@v2
- name: Install asdf
uses: asdf-vm/actions/setup@v3
- name: Install Terraform with asdf
run: |
asdf plugin add terraform
asdf plugin add opentofu
asdf install terraform
asdf install opentofu
### Linting
- name: Check Terramate formatting
run: terramate fmt --check
- name: Check Terraform formatting
run: terraform fmt -recursive -check -diff
### Check for changed stacks
- name: List changed stacks
id: list-changed
run: terramate list --changed
### Configure cloud credentials
# - name: 'configure azure credentials'
# if: steps.list-changed.outputs.stdout
# uses: azure/login@v2
# with:
# client-id: ${{ secrets.azure_client_id }}
# tenant-id: ${{ secrets.azure_tenant_id }}
# subscription-id: ${{ secrets.azure_subscription_id }}
# - name: verify azure credentials
# if: steps.list-changed.outputs.stdout
# run: |
# az account show
### Run the Terraform preview via Terramate in each changed stack
- name: Run Terraform init in all changed stacks
if: steps.list-changed.outputs.stdout
run: |
terramate script run \
--changed \
--parallel 1 \
init
env:
GITHUB_TOKEN: ${{ github.token }}
ARM_USE_OIDC: true
ARM_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
ARM_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
ARM_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- name: Plan Terraform changes in changed stacks
if: steps.list-changed.outputs.stdout
run: |
terramate script run \
--changed \
--parallel 5 \
--continue-on-error \
-- \
preview
env:
GITHUB_TOKEN: ${{ github.token }}
ARM_USE_OIDC: true
ARM_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
ARM_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
ARM_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}