Skip to content

Commit

Permalink
Modify workflow to support refactored version
Browse files Browse the repository at this point in the history
  • Loading branch information
msrn committed Jan 6, 2022
1 parent 5b1d81b commit 3bc199d
Showing 1 changed file with 89 additions and 8 deletions.
97 changes: 89 additions & 8 deletions .github/workflows/terraform-plan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,71 @@ on:

env:
TF_WORKSPACE: gha
ARM_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
ARM_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
ARM_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
ARM_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}

jobs:
terraform:
name: 'Terraform Validate and plan'
test_storagerg_module:
name: 'Test and deploy 01_Storage_rg module with Terraform Validate and plan'
runs-on: ubuntu-latest
if: contains(github.event.pull_request.labels.*.name, 'safe-to-test')

env:
ARM_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
ARM_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
ARM_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
ARM_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}

# Use the Bash shell regardless whether the GitHub Actions runner is ubuntu-latest, macos-latest, or windows-latest
defaults:
run:
shell: bash
working-directory: ./01_storage_rg
steps:
# Checkout the repository to the GitHub Actions runner
- name: Checkout
uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.sha }}

# Install the latest version of Terraform CLI. Enable wrapper for output
- name: Setup Terraform
uses: hashicorp/setup-terraform@v1
with:
terraform_wrapper: true

# 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

# Validate config files
- name: Terraform Validate
id: validate
run: terraform validate -no-color

# Checks that all Terraform configuration files adhere to a canonical format
- name: Terraform Format
id: fmt
run: terraform fmt -recursive -check -list=true
#continue-on-error: true

# Generates an execution plan for Terraform
- name: Terraform Plan
id: plan
run: terraform plan
#continue-on-error: true
- name: Terraform Apply
id: apply
run: terraform apply -auto-approve

test_deployhono_module:
name: 'Test 02_deploy_hono module with Terraform Validate and plan'
needs: test_storagerg_module
runs-on: ubuntu-latest
if: contains(github.event.pull_request.labels.*.name, 'safe-to-test')

# Use the Bash shell regardless whether the GitHub Actions runner is ubuntu-latest, macos-latest, or windows-latest
defaults:
run:
shell: bash
working-directory: ./02_deployHono
steps:
# Checkout the repository to the GitHub Actions runner
- name: Checkout
Expand Down Expand Up @@ -61,6 +108,40 @@ jobs:
id: plan
run: terraform plan
#continue-on-error: true

destroy_storagerg_module:
name: 'Destroy 01_Storage_rg module from Azure subscription'
needs: test_deployhono_module
runs-on: ubuntu-latest
if: contains(github.event.pull_request.labels.*.name, 'safe-to-test')

# Use the Bash shell regardless whether the GitHub Actions runner is ubuntu-latest, macos-latest, or windows-latest
defaults:
run:
shell: bash
working-directory: ./01_storage_rg
steps:
# Checkout the repository to the GitHub Actions runner
- name: Checkout
uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.sha }}

# Install the latest version of Terraform CLI. Enable wrapper for output
- name: Setup Terraform
uses: hashicorp/setup-terraform@v1
with:
terraform_wrapper: true

# 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

- name: Terraform Destroy
id: destroy
run: terraform destroy -auto-approve


# TODO
# Make a better output
Expand Down

0 comments on commit 3bc199d

Please sign in to comment.