diff --git a/.github/workflows/tf-azure-deploy.yml b/.github/workflows/tf-azure-deploy.yml index 4b2ee25f9..608dc8f5d 100644 --- a/.github/workflows/tf-azure-deploy.yml +++ b/.github/workflows/tf-azure-deploy.yml @@ -75,6 +75,11 @@ jobs: jq 'with_entries(.key |= ascii_downcase)' tmp-secrets.json > web-secrets.auto.tfvars.json jq 'with_entries(.key |= ascii_downcase)' tmp-vars.json > web-vars.auto.tfvars.json + - name: Terraform import + id: tf-import + run: > + terraform import azurerm_resource_group.rg /subscriptions/***/resourceGroups/s195d01-hfeyp-rg + # Generates an execution plan for Terraform # An exit code of 0 indicated no changes, 1 a terraform failure, 2 there are pending changes. - name: Terraform Plan @@ -82,13 +87,13 @@ jobs: run: | export exitcode=0 terraform plan -detailed-exitcode -no-color -out tfplan || export exitcode=$? - + echo "exitcode=$exitcode" >> $GITHUB_OUTPUT - + if [ $exitcode -eq 1 ]; then echo Terraform Plan Failed! exit 1 - else + else exit 0 fi @@ -104,7 +109,7 @@ jobs: id: tf-plan-string run: | TERRAFORM_PLAN=$(terraform show -no-color tfplan) - + delimiter="$(openssl rand -hex 8)" echo "summary<<${delimiter}" >> $GITHUB_OUTPUT echo "## Terraform Plan Output" >> $GITHUB_OUTPUT @@ -162,6 +167,11 @@ jobs: jq 'with_entries(.key |= ascii_downcase)' tmp-secrets.json > web-secrets.auto.tfvars.json jq 'with_entries(.key |= ascii_downcase)' tmp-vars.json > web-vars.auto.tfvars.json + - name: Terraform import + id: tf-import + run: > + terraform import azurerm_resource_group.rg /subscriptions/***/resourceGroups/s195d01-hfeyp-rg + # Download saved plan from artifacts - name: Download Terraform Plan uses: actions/download-artifact@v3 @@ -171,4 +181,4 @@ jobs: # Terraform Apply - name: Terraform Apply - run: terraform apply -auto-approve tfplan/tfplan \ No newline at end of file + run: terraform apply -auto-approve tfplan/tfplan