Skip to content

test: just a CI test #75

test: just a CI test

test: just a CI test #75

Workflow file for this run

name: PR - Terraform
on:
pull_request:
paths:
- 'examples/**'
- 'tests/**'
- '**.tf'
permissions:
id-token: write
pull-requests: write
jobs:
terraform:
name: Terraform
runs-on: ubuntu-latest
timeout-minutes: 15
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TF_IN_AUTOMATION: true
TFDIR: examples
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Configure AWS credentials
if: startsWith(github.repository, 'ventx/terraform-aws-')
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: ${{ secrets.AWS_DEFAULT_REGION }}
role-to-assume: ${{ secrets.AWS_GH_OIDC }}
- name: Set Versions
run: |
TFVER=$(grep .tool-versions -e "terraform" | sed "s/terraform \(.*\)/\1/")
echo "TFVERSION=$TFVER" >> $GITHUB_ENV
- name: Setup Terraform
uses: hashicorp/setup-terraform@v1
with:
terraform_version: ${{ env.TFVERSION }}
- name: Terraform Format
id: fmt
run: terraform fmt -check -recursive
continue-on-error: true
- name: Terraform Init (test)
id: init-test
run: terraform init
- name: Terraform Test
id: test
run: terraform test -verbose
continue-on-error: true
- name: Terraform Init (examples)
id: init
run: terraform -chdir=${{ env.TFDIR }} init
- name: Terraform Validate
id: validate
run: terraform -chdir=${{ env.TFDIR }} validate -no-color
- name: Terraform Plan
id: plan
run: terraform -chdir=${{ env.TFDIR }} plan -no-color -input=false
continue-on-error: true
- name: Update Pull Request
uses: actions/github-script@v6
if: github.event_name == 'pull_request'
env:
PLAN: "terraform\n${{ steps.plan.outputs.stdout }}"
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const output = `#### Terraform Format and Style 🖌\`${{ steps.fmt.outcome }}\`
#### Terraform Initialization ⚙️\`${{ steps.init.outcome }}\`
#### Terraform Plan 📖\`${{ steps.plan.outcome }}\`
#### Terraform Validation 🤖\`${{ steps.validate.outcome }}\`
<details><summary>Show Plan</summary>
\`\`\`\n
${process.env.PLAN}
\`\`\`
</details>
*Pushed by: @${{ github.actor }}, Action: \`${{ github.event_name }}\`*`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: output
})