From 98eea39eef4de8cfd5affc23f5034c0bdd2de7c6 Mon Sep 17 00:00:00 2001 From: iabhee Date: Fri, 20 Dec 2024 13:05:53 -0600 Subject: [PATCH] update workflows --- .github/workflows/terraform-apply.yml | 8 ++++++++ .github/workflows/terraform-plan.yml | 19 ++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/.github/workflows/terraform-apply.yml b/.github/workflows/terraform-apply.yml index fb1d13f..3817d60 100644 --- a/.github/workflows/terraform-apply.yml +++ b/.github/workflows/terraform-apply.yml @@ -31,6 +31,13 @@ jobs: run: terraform init working-directory: ${{ env.CONFIG_DIRECTORY }} + - name: Mask Azure Subscription ID + run: | + SUBSCRIPTION_ID=$(terraform plan | grep -oP '/subscriptions/\K[a-f0-9-]+') + if [ -n "$SUBSCRIPTION_ID" ]; then + echo "::add-mask::$SUBSCRIPTION_ID" + fi + - name: Terraform Plan id: plan run: terraform plan @@ -42,6 +49,7 @@ jobs: working-directory: ${{ env.CONFIG_DIRECTORY }} - name: Terraform Apply + if: github.ref == 'refs/heads/main' && github.event_name == 'push' && contains(github.event.head_commit.message, 'Merge pull request') run: terraform apply -auto-approve working-directory: ${{ env.CONFIG_DIRECTORY }} diff --git a/.github/workflows/terraform-plan.yml b/.github/workflows/terraform-plan.yml index b2d027a..4a5b8e6 100644 --- a/.github/workflows/terraform-plan.yml +++ b/.github/workflows/terraform-plan.yml @@ -26,11 +26,28 @@ jobs: with: cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }} + - name: Terraform Format + id: fmt + run: terraform fmt -write + continue-on-error: true + - name: Terraform init id: init run: terraform init working-directory: ${{ env.CONFIG_DIRECTORY }} - + + - name: Mask Azure Subscription ID + run: | + SUBSCRIPTION_ID=$(terraform plan | grep -oP '/subscriptions/\K[a-f0-9-]+') + if [ -n "$SUBSCRIPTION_ID" ]; then + echo "::add-mask::$SUBSCRIPTION_ID" + fi + + - name: Terraform Validate + id: validate + run: terraform validate -no-color + continue-on-error: true + - name: Terraform Plan id: plan run: terraform plan