Skip to content

Show plan in PR comment #4

Show plan in PR comment

Show plan in PR comment #4

Workflow file for this run

name: Terraform
on:
push:
branches: [main]
pull_request:
jobs:
run:
name: Run
runs-on: ubuntu-22.04
permissions:
contents: read
pull-requests: write
env:
TF_HTTP_PASSWORD: ${{ github.token }}
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: hashicorp/setup-terraform@v3
with:
terraform_version: "1.6.6"
- run: terraform init
- run: |
terraform plan -out=tfplan > summary.txt
- name: Show plan on PR
uses: actions/github-script@v6
if: ${{ github.event_name == 'pull_request' }}
with:
github-token: ${{ github.token }}
script: |
const fs = require('fs').promises
const plan = await fs.readFile('summary.txt', 'utf-8')
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: plan
})