Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reusable Terraform Action #445

Merged
merged 3 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 4 additions & 22 deletions .github/workflows/_terraform-apply.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ on:
deploy-env:
type: string
required: true
terraform_version:
description: Terraform version
required: false
default: "1.10.4"
type: string

env:
DEPLOY_ENV: ${{ inputs.deploy-env }}
Expand Down Expand Up @@ -44,7 +39,7 @@ jobs:
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT

- uses: actions/cache@v3
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
Expand All @@ -55,23 +50,10 @@ jobs:
- name: Install dependencies
run: pnpm install

- uses: actions/cache@v3
name: Check Cache for Terraform CLI
id: terraform-cache
- name: Setup Terraform
uses: hashicorp/setup-terraform@v3
with:
path: /usr/local/bin/terraform
key: terraform-${{ inputs.terraform_version }}

- name: Install Terraform CLI
if: steps.terraform-cache.outputs.cache-hit != 'true'
run: |
sudo apt-get update && sudo apt-get install -y wget unzip
wget https://releases.hashicorp.com/terraform/${{ inputs.terraform_version }}/terraform_${{ inputs.terraform_version }}_linux_amd64.zip
unzip terraform_${{ inputs.terraform_version }}_linux_amd64.zip
sudo mv terraform /usr/local/bin/

- name: Verify Terraform Installation
run: terraform --version
terraform_version: "1.10.4"

- name: Initialize Terraform CDK configuration
shell: bash
Expand Down
26 changes: 4 additions & 22 deletions .github/workflows/_terraform-plan-pr-comment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ on:
deploy-env:
required: true
type: string
terraform_version:
description: Terraform version
required: false
default: "1.10.4"
type: string

jobs:
terraform:
Expand Down Expand Up @@ -46,7 +41,7 @@ jobs:
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT

- uses: actions/cache@v3
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
Expand All @@ -57,23 +52,10 @@ jobs:
- name: Install dependencies
run: pnpm install

- uses: actions/cache@v3
name: Check Cache for Terraform CLI
id: terraform-cache
- name: Setup Terraform
uses: hashicorp/setup-terraform@v3
with:
path: /usr/local/bin/terraform
key: terraform-${{ inputs.terraform_version }}

- name: Install Terraform CLI
if: steps.terraform-cache.outputs.cache-hit != 'true'
run: |
sudo apt-get update && sudo apt-get install -y wget unzip
wget https://releases.hashicorp.com/terraform/${{ inputs.terraform_version }}/terraform_${{ inputs.terraform_version }}_linux_amd64.zip
unzip terraform_${{ inputs.terraform_version }}_linux_amd64.zip
sudo mv terraform /usr/local/bin/

- name: Verify Terraform Installation
run: terraform --version
terraform_version: "1.10.4"

- name: Initialize Terraform CDK configuration
shell: bash
Expand Down
24 changes: 3 additions & 21 deletions .github/workflows/_validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@ on:
required: false
default: "1.48.1"
type: string
terraform_version:
description: Terraform version
required: false
default: "1.10.4"
type: string

jobs:
run-tests:
Expand Down Expand Up @@ -97,23 +92,10 @@ jobs:
shell: bash
run: AUTH_SECRET=not-super-secret pnpm test:ci

- uses: actions/cache@v3
name: Check Cache for Terraform CLI
id: terraform-cache
- name: Setup Terraform
uses: hashicorp/setup-terraform@v3
with:
path: /usr/local/bin/terraform
key: terraform-${{ inputs.terraform_version }}

- name: Install Terraform CLI
if: steps.terraform-cache.outputs.cache-hit != 'true'
run: |
sudo apt-get update && sudo apt-get install -y wget unzip
wget https://releases.hashicorp.com/terraform/${{ inputs.terraform_version }}/terraform_${{ inputs.terraform_version }}_linux_amd64.zip
unzip terraform_${{ inputs.terraform_version }}_linux_amd64.zip
sudo mv terraform /usr/local/bin/

- name: Verify Terraform Installation
run: terraform --version
terraform_version: "1.10.4"

- name: Initialize Terraform CDK configuration
shell: bash
Expand Down
Loading