Skip to content

fix: Fix tfcmt pipeline, split vars #6

fix: Fix tfcmt pipeline, split vars

fix: Fix tfcmt pipeline, split vars #6

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' || 'Plan' }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
module: ["github"]
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
if [ "${{ matrix.module }}" = "github" ]; then
{
echo "app_terraform_io_token = ${{ secrets.APP_TERRAFORM_IO_TOKEN }}"
echo "github_provider_app_id = ${{ secrets.ACTIONS_PYTHON_CI_APP_ID }}"
echo "github_provider_app_installation_id = ${{ secrets.ACTIONS_PYTHON_CI_APP_INSTALLATION_ID }}"
echo "github_provider_app_pem_file = ${{ secrets.ACTIONS_PYTHON_CI_APP_PEM_FILE }}"
} > github.auto.tfvars
fi
working-directory: ${{ matrix.module }}
- name: Plan
if: ${{ github.event_name == 'pull_request' }}
run: |
tfcmt -var "target:${{ matrix.module }}" plan -patch -- tofu plan -no-color
env:
GITHUB_TOKEN: ${{ steps.create-github-app-token.outputs.token }}
working-directory: ${{ matrix.module }}
- name: Apply
if: ${{ github.event_name == 'push' }}
run: |
tfcmt -var "target:${{ matrix.module }}" apply -- tofu apply -auto-approve
env:
GITHUB_TOKEN: ${{ steps.create-github-app-token.outputs.token }}
working-directory: ${{ matrix.module }}