Skip to content

Merge pull request #5 from y-popov/query-jsons #30

Merge pull request #5 from y-popov/query-jsons

Merge pull request #5 from y-popov/query-jsons #30

Workflow file for this run

name: 'Terraform'
on:
push:
branches:
- master
pull_request:
paths:
- 'main.tf'
jobs:
terraform:
name: 'Terraform'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- id: auth
name: Authentication
uses: google-github-actions/auth@v0
with:
credentials_json: ${{ secrets.GOOGLE_SERVICE_ACCOUNT }}
- uses: hashicorp/setup-terraform@v1
with:
terraform_wrapper: true
- name: Terraform Init
id: init
run: terraform init
- name: Terraform Validate
id: validate
run: terraform validate -no-color
- name: Terraform Plan
id: plan
if: github.event_name == 'pull_request'
run: terraform plan -no-color
env:
TF_VAR_PROJECT: ${{ secrets.TF_VAR_PROJECT }}
continue-on-error: true
- name: Update Pull Request
uses: actions/[email protected]
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>
*Pusher: @${{ github.actor }}, Action: \`${{ github.event_name }}\`*`;
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: output
})
- name: Terraform Plan Status
if: steps.plan.outcome == 'failure'
run: exit 1
- name: Terraform Apply
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
run: terraform apply -auto-approve
env:
TF_VAR_PROJECT: ${{ secrets.TF_VAR_PROJECT }}