From e16cba9e747d591223fb9f10fa4e4b9046907093 Mon Sep 17 00:00:00 2001 From: sumanmanna134 Date: Sat, 21 Sep 2024 04:01:06 +0530 Subject: [PATCH] add actions --- .github/workflows/terraform.yaml | 50 ++++++++++++++++++++++++++++++++ azure/azvar.tf | 3 -- azure/provider.tf | 5 ---- 3 files changed, 50 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/terraform.yaml diff --git a/.github/workflows/terraform.yaml b/.github/workflows/terraform.yaml new file mode 100644 index 0000000..89c2efe --- /dev/null +++ b/.github/workflows/terraform.yaml @@ -0,0 +1,50 @@ +name: 'Terraform Automation' + +on: + push: + branches: + - main + pull_request: + +jobs: + terraform: + name: 'Build Azure Infra' + runs-on: ubuntu-latest + permissions: + pull-requests: write + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Terraform Setup + uses: hashicorp/setup-terraform@v2 + with: + cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }} + + - name: Select Azure + id: SA + run: cd azure + + - name: Terraform Format + id: fmt + run: terraform fmt + + - name: Terraform init + id: init + run: terraform init + + - name: Terraform validate + id: validate + run: terraform validate + + - name: plan + run: terraform plan -input=false + continue-on-error: true + + - name: Terraform Plan Status + if: steps.plan.outcome == 'failure' + run: exit 1 + + - name: Terraform Apply + if: step.plan.outcome == 'success' + run: terraform apply -auto-approve -input=false diff --git a/azure/azvar.tf b/azure/azvar.tf index 828f2dc..247f81b 100644 --- a/azure/azvar.tf +++ b/azure/azvar.tf @@ -53,9 +53,6 @@ variable "tenant_id" { } -variable "GITHUB_TOKEN" { - -} diff --git a/azure/provider.tf b/azure/provider.tf index 337199c..b9312b9 100644 --- a/azure/provider.tf +++ b/azure/provider.tf @@ -29,8 +29,3 @@ provider "azurerm" { client_secret = var.client_secret features {} } - -provider "github" { - token = var.GITHUB_TOKEN - -}