Skip to content

Commit

Permalink
Add .github/workflows/terraform.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
David Arnold committed Feb 26, 2025
1 parent 3dd492d commit c36493e
Showing 1 changed file with 84 additions and 0 deletions.
84 changes: 84 additions & 0 deletions .github/workflows/terraform.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: "Terraform Validate"

on:
workflow_dispatch:
push:
branches:
- main

env:
GITHUB_OWNER: ${{ vars.GH_ORG }}
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
GOOGLE_CREDENTIALS: ${{ secrets.GOOGLE_CREDENTIALS }}
TF_WORKSPACE: happypathway
TFE_TOKEN: ${{ secrets.TFE_TOKEN }}

jobs:
setup-terraform:
outputs:
commit_sha: ${{ steps.checkout.outputs.commit }}

runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
id: checkout

- name: Setup Terraform
uses: hashicorp/setup-terraform@v3.1.2
with:
terraform_version: ${{ vars.terraform_version }}
cli_config_credentials_token: ${{ secrets.TFE_TOKEN }}
cli_config_credentials_hostname: ${{ vars.terraform_api }}

- name: terraform init
run: terraform init -upgrade

- uses: actions/upload-artifact@master
name: Archive Configuration
if: github.ref == 'refs/heads/main'
with:
name: terraform_dir
path: .terraform
retention-days: 1
include-hidden-files: true

- uses: actions/upload-artifact@master
name: Archive Lockfile
if: github.ref == 'refs/heads/main'
with:
name: terraform_lockfile
path: .terraform.lock.hcl
retention-days: 1
include-hidden-files: true

terraform-validate:
needs: setup-terraform
uses: HappyPathway/centralized-actions/.github/workflows/terraform-test.yml@main
with:
terraform_version: ${{ vars.terraform_version }}
terraform_api: ${{ vars.terraform_api }}
github_username: ${{ github.actor }}
github_email: ${{ github.actor }}@roknsound.com
github_org: ${{ github.repository_owner }}
setup_terraform: true
terraform_init: false
cache: ${{ github.workspace }}
download_cache: true
commit_sha: ${{ needs.setup-terraform.outputs.commit_sha }}
secrets:
TFE_TOKEN: ${{ secrets.TFE_TOKEN }}
GH_TOKEN: ${{ secrets.GH_TOKEN }}
GOOGLE_CREDENTIALS: ${{ secrets.GOOGLE_CREDENTIALS }}

gtag:
needs: terraform-validate
if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
uses: HappyPathway/centralized-actions/.github/workflows/gtag.yml@main
with:
patch: true
github_org: ${{ vars.GH_ORG }}
github_username: ${{ vars.GH_USERNAME }}
github_email: ${{ vars.GH_EMAIL }}
secrets:
GH_TOKEN: ${{ secrets.GH_TOKEN }}

0 comments on commit c36493e

Please sign in to comment.