terraform-github-actions

terraform-new-workspace action

This is one of a suite of Terraform related actions - find them at dflook/terraform-github-actions.

Creates a new Terraform workspace. If the workspace already exists, succeeds without doing anything.

Inputs

Environment Variables

Example usage

This example creates a workspace named after the git branch when the associated PR is opened or updated, and deploys a test environment to it.

name: Run integration tests

on: [pull_request]

jobs:
  integration:
    runs-on: ubuntu-latest
    name: Run integration tests
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Use branch workspace
        uses: dflook/terraform-new-workspace@v1
        with:
          path: terraform
          workspace: $

      - name: Deploy test infrastrucutre
        uses: dflook/terraform-apply@v1
        with:
          path: terraform
          workspace: $
          auto_approve: true