Plan Workflow #11
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: Plan Workflow | |
on: | |
workflow_dispatch: | |
pull_request: | |
branches: | |
- master | |
paths: | |
- 'infra/**' | |
permissions: | |
contents: read | |
packages: write | |
id-token: write | |
pull-requests: write | |
env: | |
# Setting an environment variable with the value of a configuration variable | |
APP_NAME: ${{ vars.APP_NAME }} | |
TF_VAR_discord_token: ${{ secrets.DISCORD_TOKEN }} | |
TF_VAR_clash_token: ${{ secrets.CLASH_TOKEN }} | |
jobs: | |
plan: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: ./infra/environments/dev | |
if: github.actor == 'jburns24' | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
# - name: 'Az CLI login' | |
# uses: azure/login@v1 | |
# with: | |
# client-id: ${{ secrets.ARM_CLIENT_ID }} | |
# tenant-id: ${{ secrets.ARM_TENANT_ID }} | |
# subscription-id: ${{ secrets.ARM_SUBSCRIPTION_ID }} | |
- uses: alexellis/arkade-get@master | |
with: | |
# vault: latest | |
# jq: latest | |
terraform: latest | |
terragrunt: latest | |
- name: Terragrunt hcl check | |
run: terragrunt hclfmt --terragrunt-check | |
- name: Terraform fmt check | |
run: terraform fmt -check -recursive | |
- name: Terragrunt validate check | |
run: terragrunt run-all validate --terragrunt-non-interactive | |
env: | |
ARM_TENANT_ID: ${{ secrets.ARM_TENANT_ID }} | |
ARM_CLIENT_ID: ${{ secrets.ARM_CLIENT_ID }} | |
# ARM_CLIENT_SECRET: ${{ secrets.ARM_CLIENT_SECRET}} | |
ARM_SUBSCRIPTION_ID: ${{ secrets.ARM_SUBSCRIPTION_ID }} | |
ARM_USE_OIDC: "true" | |
- name: Terragrunt Plan | |
id: terragrunt_plan | |
run: | | |
pwd | |
terragrunt init --terragrunt-non-interactive | |
terragrunt plan --terragrunt-non-interactive -out plan.out | |
terragrunt show --terragrunt-non-interactive -no-color -json plan.out > plan.json | |
continue-on-error: true # Continue on error to ensure the plan is added as a comment on the PR. | |
env: | |
ARM_TENANT_ID: ${{ secrets.ARM_TENANT_ID }} | |
ARM_CLIENT_ID: ${{ secrets.ARM_CLIENT_ID }} | |
# ARM_CLIENT_SECRET: ${{ secrets.ARM_CLIENT_SECRET}} | |
ARM_SUBSCRIPTION_ID: ${{ secrets.ARM_SUBSCRIPTION_ID }} | |
ARM_USE_OIDC: "true" | |
- uses: liatrio/[email protected] | |
with: | |
json-file: infra/environments/dev/plan.json | |
- name: Status | |
if: contains(steps.*.outcome, 'failure') | |
run: exit 1 |