From 2452ceab1b8266f529cd9298eef26af71fa8773f Mon Sep 17 00:00:00 2001 From: Daniel Flook Date: Sat, 25 Jul 2020 13:58:44 +0000 Subject: [PATCH] v1.4.0 --- README.md | 34 +++++++++++++++++++++++++++++++++- action.yaml | 2 +- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 76a9a7b..c13c576 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ This is one of a suite of terraform related actions - find them at [dflook/terraform-github-actions](https://github.com/dflook/terraform-github-actions). This actions generates a terraform plan. -If the action is run on `pull_request` events it will add a comment on the PR containing the generated plan. +If the triggering event relates to a PR it will add a comment on the PR containing the generated plan.

@@ -111,6 +111,8 @@ The [dflook/terraform-apply](https://github.com/dflook/terraform-github-actions/ ## Example usage +### Automatically generating a plan + This example workflow runs on every push to an open pull request, and create or updates a comment with the terraform plan @@ -134,3 +136,33 @@ jobs: with: path: my-terraform-config ``` + +### Generating a plan using a comment + +This workflow generates a plan on demand, triggered by someone +commenting `terraform plan` on the PR. The action will create or update +a comment on the PR with the generated plan. + +```yaml +name: Terraform Plan + +on: [issue_comment] + +jobs: + plan: + if: github.event.issue.pull_request && contains(github.event.comment.body, 'terraform plan') + runs-on: ubuntu-latest + name: Create terraform plan + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + ref: refs/pull/${{ github.event.issue.number }}/merge + + - name: terraform plan + uses: dflook/terraform-plan@v1 + with: + path: my-terraform-config +``` diff --git a/action.yaml b/action.yaml index 5e34b6e..ddbd019 100644 --- a/action.yaml +++ b/action.yaml @@ -41,7 +41,7 @@ outputs: runs: using: docker - image: docker://danielflook/terraform-github-actions:v1.3.1 + image: docker://danielflook/terraform-github-actions:v1.4.0 entrypoint: /entrypoints/plan.sh branding: