From a39d04dd3a43e77ecea5ed462235163f4e78e6c9 Mon Sep 17 00:00:00 2001 From: Sergio Valverde Date: Sat, 16 Mar 2024 02:50:29 +0100 Subject: [PATCH] fix terraform workflow --- .github/workflows/terraform.yml | 6 +++++- apps/github-as-code/Makefile | 6 ++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/terraform.yml b/.github/workflows/terraform.yml index c98378e..cc7b5b7 100644 --- a/.github/workflows/terraform.yml +++ b/.github/workflows/terraform.yml @@ -22,7 +22,7 @@ jobs: steps: # Checkout the repository to the GitHub Actions runner - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 # Install the latest version of Terraform CLI and configure the Terraform CLI configuration file with a Terraform Cloud user API token - name: Setup Terraform @@ -33,17 +33,21 @@ jobs: # Initialize a new or existing Terraform working directory by creating initial files, loading any remote state, downloading modules, etc. - name: Terraform Init run: terraform init + working-directory: apps/github-as-code # Checks that all Terraform configuration files adhere to a canonical format - name: Terraform Format run: terraform fmt -check + working-directory: apps/github-as-code # Generates an execution plan for Terraform - name: Terraform Plan run: terraform plan -input=false + working-directory: apps/github-as-code # On push to "main", build or change infrastructure according to Terraform configuration files # Note: It is recommended to set up a required "strict" status check in your repository for "Terraform Cloud". See the documentation on "strict" required status checks for more information: https://help.github.com/en/github/administering-a-repository/types-of-required-status-checks - name: Terraform Apply if: github.ref == 'refs/heads/"main"' && github.event_name == 'push' run: terraform apply -auto-approve -input=false + working-directory: apps/github-as-code diff --git a/apps/github-as-code/Makefile b/apps/github-as-code/Makefile index 7eed4e7..acd30e7 100644 --- a/apps/github-as-code/Makefile +++ b/apps/github-as-code/Makefile @@ -37,4 +37,10 @@ move: ## move resource $(terraform_project_cmd) state mv \ 'github_repository.admin' 'module.admin.github_repository.main' +ci: ## ci + $(terraform_project_cmd) init + $(terraform_project_cmd) fmt -check + $(terraform_project_cmd) plan -input=false +cd: ## cd + $(terraform_project_cmd) apply -auto-approve -input=false