File tree Expand file tree Collapse file tree 7 files changed +127
-53
lines changed
Expand file tree Collapse file tree 7 files changed +127
-53
lines changed Original file line number Diff line number Diff line change 3636 token : ${{ github.token }}
3737 planfile : .planfile
3838 working-directory : tests/ci/1-change
39+ skip-comment : ${{ github.event.pull_request.head.repo.full_name != 'borchero/terraform-plan-comment' }}
Original file line number Diff line number Diff line change @@ -44,7 +44,30 @@ GitHub Action to post the output of `terraform plan` to a pull request comment.
4444
4545## Parameters
4646
47- This action provides a few input parameters that allow for customization:
47+ ` ` ` yaml
48+ - uses : borchero/terraform-plan-comment@v2
49+ with :
50+ # GitHub token for API access (Required)
51+ token : " "
52+
53+ # Path to the Terraform plan file (Required)
54+ planfile : " "
55+
56+ # Command to execute the Terraform binary
57+ terraform-cmd : terraform
58+
59+ # Directory where Terraform should be called
60+ working-directory : " ."
61+
62+ # Header for the PR comment
63+ header : 📝 Terraform Plan
64+
65+ # Skip comments for empty plans
66+ skip-empty : false
67+
68+ # Skip PR comment creation entirely. When enabled, the plan will still be available in the step summary
69+ skip-comment : false
70+ ` ` `
4871
4972### ` token` (required)
5073
@@ -76,3 +99,18 @@ The directory where the Terraform binary ought to be called. Defaults to `$GITHU
7699
77100The header that is used for the pull request comment posted by this action. Changing the default allows to distinguish
78101multiple Terraform runs : each sticky pull request comment is identified by its header.
102+
103+ # ## `skip-empty`
104+
105+ Whether to skip posting a pull request comment when no changes need to be performed. Defaults to `false`.
106+
107+ # ## `skip-comment`
108+
109+ Whether to skip posting a pull request comment entirely. When enabled, the plan will still be available in the step
110+ summary.
111+
112+ # # Outputs
113+
114+ This action provides the following output :
115+
116+ - `markdown` : The raw markdown output of the terraform plan
Original file line number Diff line number Diff line change @@ -27,6 +27,13 @@ inputs:
2727 description : Whether to skip posting a pull request comment when no changes need to be performed.
2828 required : true
2929 default : " false"
30+ skip-comment :
31+ description : Whether to skip posting a pull request comment entirely.
32+ required : true
33+ default : " false"
34+ outputs :
35+ markdown :
36+ description : The raw markdown output of the terraform plan
3037runs :
3138 using : node20
3239 main : dist/index.js
Original file line number Diff line number Diff line change @@ -44,7 +44,7 @@ function renderBody(plan: RenderedPlan): string {
4444 return body
4545}
4646
47- export function renderComment ( {
47+ export function renderMarkdown ( {
4848 plan,
4949 header,
5050 includeFooter
@@ -59,9 +59,10 @@ export function renderComment({
5959 // Build footer
6060 let footer = ''
6161 if ( includeFooter === undefined || includeFooter === true ) {
62- footer =
63- `\n\n---\n\n_Triggered by @${ github . context . actor } ,` +
64- ` Commit: \`${ ( github . context . payload as PullRequestEvent ) . pull_request . head . sha } \`_`
62+ footer = `\n\n---\n\n_Triggered by @${ github . context . actor } `
63+ if ( github . context . eventName === 'pull_request' ) {
64+ footer += `, Commit: \`${ ( github . context . payload as PullRequestEvent ) . pull_request . head . sha } \`_`
65+ }
6566 }
6667
6768 return `## ${ header } \n\n${ body } ${ footer } `
You can’t perform that action at this time.
0 commit comments