Skip to content

feat: Add terraform-cloud configurations #9

feat: Add terraform-cloud configurations

feat: Add terraform-cloud configurations #9

Workflow file for this run

name: Tfcmt
on:
push:
branches: [main]
paths: ["**.tf", "**.tfvars", "**/.terraform.lock.hcl"]
pull_request:
types: [opened, reopened, synchronize]
paths: ["**.tf", "**.tfvars", "**/.terraform.lock.hcl"]
jobs:
opentofu-tfcmt:
name: ${{ github.event_name == 'push' && 'Apply (${{ matrix.workspace }})' || 'Plan (${{ matrix.workspace }})' }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
workspace: ["github", "terraform-cloud"]
steps:
- uses: actions/checkout@v4
- uses: actions/create-github-app-token@v1
id: create-github-app-token
with:
app-id: ${{ secrets.ACTIONS_PYTHON_CI_APP_ID }}
private-key: ${{ secrets.ACTIONS_PYTHON_CI_APP_PEM_FILE }}
- uses: kislerdm/setup-opentofu@main
with:
cli_config_credentials_token: ${{ secrets.APP_TERRAFORM_IO_TOKEN }}
tofu_version: 1.6.0-alpha1
- uses: shmokmt/actions-setup-tfcmt@v2
with:
version: v4.7.1
- name: Init
run: tofu init
working-directory: ${{ matrix.workspace }}
- name: Plan
if: ${{ github.event_name == 'pull_request' }}
run: |
tfcmt -var "target:${{ matrix.workspace }}" plan -patch -- tofu plan -no-color
env:
GITHUB_TOKEN: ${{ steps.create-github-app-token.outputs.token }}
TFE_TOKEN: ${{ secrets.APP_TERRAFORM_IO_TOKEN }}
working-directory: ${{ matrix.workspace }}
- name: Apply
if: ${{ github.event_name == 'push' }}
run: |
tfcmt -var "target:${{ matrix.workspace }}" apply -- tofu apply -auto-approve
env:
GITHUB_TOKEN: ${{ steps.create-github-app-token.outputs.token }}
TFE_TOKEN: ${{ secrets.APP_TERRAFORM_IO_TOKEN }}
working-directory: ${{ matrix.workspace }}