mercari / tfnotify

A CLI command to parse Terraform execution result and notify it to GitHub
MIT License
620 stars 91 forks source link

Add support for GitHub Actions workflow triggered by Pull Request #77

Closed dtan4 closed 2 years ago

dtan4 commented 4 years ago

WHAT

This change enables tfnotify to put comments on GitHub Pull Request, from GitHub Actions triggered by the same Pull Request (on.pull_request).

Screenshot

image

Example GitHub Actions workflow

# .github/workflows/terraform-plan.yaml

name: "terraform plan for AWS"
on:
  pull_request:

jobs:
  terraform:
    name: "Terraform"
    runs-on: ubuntu-latest
    steps:
      - name: "Checkout"
        uses: actions/checkout@v2
      - name: "Terraform Init"
        run: terraform init
      - name: "Terraform Plan"
        run: terraform plan | tfnotify --config tfnotify.yaml plan

WHY

Current GitHub Actions support doesn't support workflow triggered by Pull Request because it doesn't read the target Pull Request number. Therefore, we have to use "branch push (on.branches)" as workflow trigger. Actually, tfnotify with branch-triggered workflow can also put the comment on the Pull Request timeline. However, it lacks some tfnotify features, like putting labels like no-changes based on terraform plan result. Therefore, to provide the equivalent experience to GitHub Actions users as well as other CIs, it's better to implement native Pull Request support.

babarot commented 4 years ago

Thanks! Could you look the test cases with failing?

dtan4 commented 4 years ago

Sorry for the delay... fixed the test!

mijime commented 3 years ago

I'd really like to see you merge this great PR, is there anything I can do to help?