From 14840882a9d10ad2b0b9ad08a5eef6bddcad7098 Mon Sep 17 00:00:00 2001 From: Vincent De Smet Date: Wed, 15 Jan 2025 17:46:59 +0700 Subject: [PATCH] fix: GitHub Action runners need setup-terraform Add step to install terraform --- plan/ci.go | 8 +++++--- templates/templates/.github/workflows/fogg_ci.yml.tmpl | 3 +++ testdata/github_actions/.github/workflows/fogg_ci.yml | 3 +++ .../.github/workflows/fogg_ci.yml | 3 +++ testdata/v2_full_yaml/.github/workflows/fogg_ci.yml | 3 +++ .../.github/workflows/fogg_ci.yml | 3 +++ 6 files changed, 20 insertions(+), 3 deletions(-) diff --git a/plan/ci.go b/plan/ci.go index d22713498..bbdff1258 100644 --- a/plan/ci.go +++ b/plan/ci.go @@ -41,7 +41,8 @@ type CircleCIConfig struct { type GitHubActionsCIConfig struct { CIConfig - SSHKeySecrets []string + TerraformVersion string + SSHKeySecrets []string } type AtlantisConfig struct { @@ -389,8 +390,9 @@ func (p *Plan) buildGitHubActionsConfig(c *v2.Config, foggVersion string) GitHub ciConfig = ciConfig.populateBuckets(numBuckets) return GitHubActionsCIConfig{ - CIConfig: *ciConfig, - SSHKeySecrets: sshKeySecrets, + CIConfig: *ciConfig, + SSHKeySecrets: sshKeySecrets, + TerraformVersion: v2.ResolveRequiredString(v2.TerraformVersionGetter, c.Defaults.Common, c.Global.Common), } } diff --git a/templates/templates/.github/workflows/fogg_ci.yml.tmpl b/templates/templates/.github/workflows/fogg_ci.yml.tmpl index 653357d52..3c9364499 100644 --- a/templates/templates/.github/workflows/fogg_ci.yml.tmpl +++ b/templates/templates/.github/workflows/fogg_ci.yml.tmpl @@ -21,6 +21,9 @@ jobs: with: repository: {{`${{ github.event.pull_request.head.repo.full_name }}`}} ref: {{`${{ github.event.pull_request.head.ref }}`}} + - uses: hashicorp/setup-terraform@v3 + with: + terraform_version: {{ $githubActionsCI.TerraformVersion }} - name: Cache Fogg id: cache-fogg uses: actions/cache@v4 diff --git a/testdata/github_actions/.github/workflows/fogg_ci.yml b/testdata/github_actions/.github/workflows/fogg_ci.yml index b0e6edf24..5e1625e75 100644 --- a/testdata/github_actions/.github/workflows/fogg_ci.yml +++ b/testdata/github_actions/.github/workflows/fogg_ci.yml @@ -14,6 +14,9 @@ jobs: with: repository: ${{ github.event.pull_request.head.repo.full_name }} ref: ${{ github.event.pull_request.head.ref }} + - uses: hashicorp/setup-terraform@v3 + with: + terraform_version: 1.1.1 - name: Cache Fogg id: cache-fogg uses: actions/cache@v4 diff --git a/testdata/github_actions_with_iam_role/.github/workflows/fogg_ci.yml b/testdata/github_actions_with_iam_role/.github/workflows/fogg_ci.yml index e47760160..4a892190d 100644 --- a/testdata/github_actions_with_iam_role/.github/workflows/fogg_ci.yml +++ b/testdata/github_actions_with_iam_role/.github/workflows/fogg_ci.yml @@ -18,6 +18,9 @@ jobs: with: repository: ${{ github.event.pull_request.head.repo.full_name }} ref: ${{ github.event.pull_request.head.ref }} + - uses: hashicorp/setup-terraform@v3 + with: + terraform_version: 1.1.1 - name: Cache Fogg id: cache-fogg uses: actions/cache@v4 diff --git a/testdata/v2_full_yaml/.github/workflows/fogg_ci.yml b/testdata/v2_full_yaml/.github/workflows/fogg_ci.yml index 5deb3f876..697f92482 100644 --- a/testdata/v2_full_yaml/.github/workflows/fogg_ci.yml +++ b/testdata/v2_full_yaml/.github/workflows/fogg_ci.yml @@ -18,6 +18,9 @@ jobs: with: repository: ${{ github.event.pull_request.head.repo.full_name }} ref: ${{ github.event.pull_request.head.ref }} + - uses: hashicorp/setup-terraform@v3 + with: + terraform_version: 0.100.0 - name: Cache Fogg id: cache-fogg uses: actions/cache@v4 diff --git a/testdata/v2_github_actions_with_pre_commit/.github/workflows/fogg_ci.yml b/testdata/v2_github_actions_with_pre_commit/.github/workflows/fogg_ci.yml index e8c00c5c0..92ea8d17e 100644 --- a/testdata/v2_github_actions_with_pre_commit/.github/workflows/fogg_ci.yml +++ b/testdata/v2_github_actions_with_pre_commit/.github/workflows/fogg_ci.yml @@ -18,6 +18,9 @@ jobs: with: repository: ${{ github.event.pull_request.head.repo.full_name }} ref: ${{ github.event.pull_request.head.ref }} + - uses: hashicorp/setup-terraform@v3 + with: + terraform_version: 1.5.7 - name: Cache Fogg id: cache-fogg uses: actions/cache@v4