From 1f101f1a5dca3b63b34b13eb2d8031946e010cf4 Mon Sep 17 00:00:00 2001 From: juan pablo Date: Mon, 12 Aug 2024 18:29:53 +0200 Subject: [PATCH] pass secrets as env vars --- .github/workflows/{go-ci.yml => ci.yml} | 40 +++++++++++++++++++- .github/workflows/tf-ci.yml | 49 ------------------------- 2 files changed, 38 insertions(+), 51 deletions(-) rename .github/workflows/{go-ci.yml => ci.yml} (61%) delete mode 100644 .github/workflows/tf-ci.yml diff --git a/.github/workflows/go-ci.yml b/.github/workflows/ci.yml similarity index 61% rename from .github/workflows/go-ci.yml rename to .github/workflows/ci.yml index cf261b6..d1d530b 100644 --- a/.github/workflows/go-ci.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,4 @@ -name: go-continuous-integration +name: continuous-integration on: pull_request: @@ -16,6 +16,8 @@ env: GO_VERSION: v1.22.0 GOLANGCI_LINT_VERSION: v1.59 GOPRIVATE: github.com/intercloud + TF_VERSION: 1.9.0 + TF_MODULE_PATH: examples/autonomi jobs: markdown-lint: @@ -68,7 +70,7 @@ jobs: go-test: runs-on: ubuntu-latest needs: - - go-mod-tidy + - golangci-lint steps: - name: checkout code uses: actions/checkout@v4 @@ -78,3 +80,37 @@ jobs: go-version: ${{ env.GO_VERSION }} - name: go test run: go test ./... -v + + tf-validate: + runs-on: ubuntu-latest + steps: + - name: checkout code + uses: actions/checkout@v4 + - name: set up terraform + uses: hashicorp/setup-terraform@v3 + with: + terraform_version: ${{ env.TF_VERSION }} + - name: terraform init + working-directory: ${{ env.TF_MODULE_PATH }} + run: terraform init + - name: terraform validate + working-directory: ${{ env.TF_MODULE_PATH }} + run: terraform validate + + tf-plan: + runs-on: ubuntu-latest + needs: + - tf-validate + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: set up terraform + uses: hashicorp/setup-terraform@v3 + with: + terraform_version: ${{ env.TF_VERSION }} + - name: terraform plan + working-directory: ${{ env.TF_MODULE_PATH }} + run: terraform plan + env: + TF_VAR_pat_token: ${{ secrets.TF_VAR_PAT_TOKEN }} + TF_VAR_aws_account_id: ${{ secrets.TF_VAR_AWS_ACCOUNT_ID }} diff --git a/.github/workflows/tf-ci.yml b/.github/workflows/tf-ci.yml deleted file mode 100644 index 083bbb8..0000000 --- a/.github/workflows/tf-ci.yml +++ /dev/null @@ -1,49 +0,0 @@ -name: terraform-continuous-integration - -on: - pull_request: - branches: - - feat/** - - fix/** - - hotfix/** - - main - push: - branches: - - main - -env: - GOPRIVATE: github.com/intercloud - TF_VERSION: 1.9.0 - TF_MODULE_PATH: examples/autonomi - -jobs: - tf-validate: - runs-on: ubuntu-latest - steps: - - name: checkout code - uses: actions/checkout@v4 - - name: set up terraform - uses: hashicorp/setup-terraform@v3 - with: - terraform_version: ${{ env.TF_VERSION }} - - name: terraform init - working-directory: ${{ env.TF_MODULE_PATH }} - run: terraform init - - name: terraform validate - working-directory: ${{ env.TF_MODULE_PATH }} - run: terraform validate - - tf-plan: - runs-on: ubuntu-latest - needs: - - tf-validate - steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: set up terraform - uses: hashicorp/setup-terraform@v3 - with: - terraform_version: ${{ env.TF_VERSION }} - - name: terraform plan - working-directory: ${{ env.TF_MODULE_PATH }} - run: terraform plan