Skip to content

ci: add workflow examples with tenv and tofu #3

ci: add workflow examples with tenv and tofu

ci: add workflow examples with tenv and tofu #3

Workflow file for this run

name: TF Tests
on:
pull_request:
types: [opened, reopened, synchronize, closed]
jobs:
tests:
runs-on: ubuntu-latest
if: github.event.action != 'closed' || github.event.pull_request.merged
permissions:
actions: read # Required for workflow query and artifact download.
contents: read # Required for repository checkout.
issues: read # Required for getting PR branch from issue comment.
pull-requests: write # Required for commenting on PR.
statuses: write # Required for setting commit status from issue comment.
strategy:
fail-fast: false
matrix:
cli_uses: [tofu, terraform]
test:
- 10_fail_invalid_resource_type
- 11_fail_data_source_error
- 50_pass_one
- 51_pass_character_limit
- 52_pass_format_diff
steps:
- name: Checkout repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Setup TF
uses: opentofu/setup-opentofu@ae80d4ecaab946d8f5ff18397fbf6d0686c6d46a # v1.0.3
- uses: hashicorp/setup-terraform@a1502cd9e758c50496cc9ac5308c4843bcd56d36 # v3.0.0
- name: Provision TF
id: tf
continue-on-error: true
uses: ./
with:
chdir_prefix: tests/
cli_uses: ${{ matrix.cli_uses }}
command_input: ${{ format('-tf={0} -chdir={1}', github.event.action != 'closed' && 'plan' || 'apply', matrix.test) }}
cache_plugins: false
recreate_comment: true
- name: Echo TF
run: |
echo "command: ${{ steps.tf.outputs.command }}"
echo "plan_id: ${{ steps.tf.outputs.plan_id }}"
echo "tf_fmt: ${{ steps.tf.outputs.tf_fmt }}"
echo "tf_output: ${{ steps.tf.outputs.tf_output }}"
- name: Echo github-script context
if: always()
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
script: console.log(JSON.stringify(context, null, 2))
- name: Echo github context
if: always()
env:
MATRIX_CONTEXT: ${{ toJSON(matrix) }}
GITHUB_CONTEXT: ${{ toJSON(github) }}
run: |
echo "$MATRIX_CONTEXT"
echo "$GITHUB_CONTEXT"