Skip to content

Commit 84048c4

Browse files
authored
Merge pull request #16 from GetTerminus/dpr-update-commenter
feat: pr-commenter v3
2 parents 67c4b1f + c5d65f4 commit 84048c4

37 files changed

+6658
-3196
lines changed
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
name: Release Beta
22

33
on:
4-
push:
5-
branches-ignore:
6-
- master
4+
pull_request:
75

86
jobs:
97
release-beta:
@@ -13,7 +11,7 @@ jobs:
1311
- name: Set Beta Git tag
1412
uses: weareyipyip/walking-tag-action@v2
1513
with:
16-
tag-name: v2-beta
14+
tag-name: v3-beta
1715
tag-message: The current beta is based on this commit
1816
env:
1917
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/test.yaml

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,22 @@
11
name: Test
22

33
on:
4-
workflow_run:
5-
workflows: [Release Beta]
6-
types:
7-
- completed
4+
pull_request:
85

96
env:
107
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
118
TERRAFORM_VERSION: "1.4.6"
129
TF_WORKSPACE: "testing"
13-
USE_BETA_VERSION: "true"
1410
COMMENTER_DEBUG: "true"
1511
GH_ACCEPT_HEADER: "Accept: application/vnd.github+json"
1612
GH_AUTH_HEADER: "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}"
1713
GH_API_VERSION: "X-GitHub-Api-Version: 2022-11-28"
1814
GH_COMMENT_URL: https://api.github.com/repos/GetTerminus/terraform-pr-commenter/issues/${{ github.event.number }}/comments
15+
TESTING: "false" #set to false when finished testing
1916

2017
jobs:
2118
set-outputs:
2219
name: Set Outputs
23-
if: ${{ github.event.workflow_run.conclusion == 'success' }}
2420
runs-on: ubuntu-latest
2521
outputs:
2622
tf_fmt_fail: ${{ steps.file_outputs.outputs.tf_fmt_fail }}
@@ -29,8 +25,10 @@ jobs:
2925
tf_plan_fail_partial: ${{ steps.file_outputs.outputs.tf_plan_fail_partial }}
3026
tf_plan_success_no_changes: ${{ steps.file_outputs.outputs.tf_plan_success_no_changes }}
3127
tf_plan_success_with_changes: ${{ steps.file_outputs.outputs.tf_plan_success_with_changes }}
28+
tf_plan_success_with_outputs: ${{ steps.file_outputs.outputs.tf_plan_success_with_outputs }}
3229
tf_plan_success_long: ${{ steps.file_outputs.outputs.tf_plan_success_long }}
3330
tf_validate_fail: ${{ steps.file_outputs.outputs.tf_validate_fail }}
31+
tflint_fail: ${{ steps.file_outputs.outputs.tflint_fail }}
3432
strategy:
3533
matrix:
3634
filenames:
@@ -40,15 +38,19 @@ jobs:
4038
- "tf_plan_fail_partial"
4139
- "tf_plan_success_no_changes"
4240
- "tf_plan_success_with_changes"
41+
- "tf_plan_success_with_outputs"
4342
- "tf_plan_success_long"
4443
- "tf_validate_fail"
44+
- "tflint_fail"
4545
steps:
4646
- uses: actions/checkout@v3
47+
if: ${{ env.TESTING == 'true' }}
4748
- name: Set Test Outputs
49+
if: ${{ env.TESTING == 'true' }}
4850
id: file_outputs
4951
run: |
5052
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
51-
53+
5254
#have to truncate so we don't get an "argument list too long" error
5355
if [[ "${{ matrix.filenames }}" == "tf_plan_success_long" ]]; then
5456
OUTPUT=$(cat ./testing/text-files/${{ matrix.filenames }}.txt)
@@ -62,18 +64,18 @@ jobs:
6264
# To test other scenarios please change the below variables as necessary.
6365
commenter-test:
6466
name: Test Commenter
65-
if: ${{ github.event.workflow_run.conclusion == 'success' }}
6667
runs-on: ubuntu-latest
6768
needs: set-outputs
6869
steps:
6970
- uses: actions/checkout@v3
71+
if: ${{ env.TESTING == 'true' }}
7072
- name: Test
71-
uses: GetTerminus/terraform-pr-commenter@v3-beta
73+
if: ${{ env.TESTING == 'true' }}
74+
uses: GetTerminus/terraform-pr-commenter@v3-beta #set to your branch for testing and switch back to v3-beta when done.
7275
with:
7376
commenter_type: plan
7477
# Should only be setting commenter_input or commenter_plan_path (commenter_plan_path only for plan commenter type)
75-
#commenter_input: ${{ needs.set-outputs.outputs.tf_plan_fail }}
76-
commenter_plan_path: ./testing/text-files/tf_plan_success_with_changes.txt
77-
commenter_exitcode: 1
78-
terraform_version: ${{ env.TERRAFORM_VERSION }}
79-
use_beta_version: ${{ env.USE_BETA_VERSION }}
78+
commenter_input: ${{ needs.set-outputs.outputs.tf_plan_success_with_outputs }}
79+
#commenter_plan_path: ./testing/text-files/tf_plan_success_with_outputs.txt
80+
commenter_exitcode: 2
81+
use_beta_version: "true"

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Changelog
22

3+
## v3.0.0
4+
- Add support for tflint.
5+
- Remove requirement to run `terraform show` internally and depend on either direct input or directing the `terraform plan` output to a txt file.
6+
- Add support for adding partial plan to the comment on failure.
7+
8+
## v2.0.0
9+
- Run `terraform show` internally to bypass github 64k limit.
10+
- Paginate comments that are greater than 64k characters and delete corresponding paginated comments on each successive rerun.
11+
- Temporarily swap out red `-` so yaml arrays aren't confused with diff-removal lines.
12+
313
## v1.5.0
414

515
- Bump to Terraform v1.0.6 internally (only affects `fmt`)

Dockerfile

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
ARG TERRAFORM_VERSION=1.0.6
1+
ARG TERRAFORM_VERSION=1.4.6
22
FROM hashicorp/terraform:${TERRAFORM_VERSION}
33

4-
LABEL repository="https://github.com/robburger/terraform-pr-commenter" \
5-
homepage="https://github.com/robburger/terraform-pr-commenter" \
6-
maintainer="Rob Burger" \
4+
LABEL repository="https://github.com/GetTerminus/terraform-pr-commenter" \
5+
homepage="https://github.com/GetTerminus/terraform-pr-commenter" \
6+
maintainer="Terminus Software" \
77
com.github.actions.name="Terraform PR Commenter" \
8-
com.github.actions.description="Adds opinionated comments to a PR from Terraform fmt/init/plan output" \
8+
com.github.actions.description="Adds comments to a PR from Terraform fmt/init/plan/tflint output." \
99
com.github.actions.icon="git-pull-request" \
10-
com.github.actions.color="purple"
10+
com.github.actions.color="blue"
1111

1212
RUN apk add --no-cache -q \
1313
bash \
@@ -16,6 +16,10 @@ RUN apk add --no-cache -q \
1616
jq
1717

1818
ADD entrypoint.sh /entrypoint.sh
19+
ADD /handlers /handlers
20+
ADD /utilities /utilities
1921
RUN chmod +x /entrypoint.sh
22+
RUN chmod +x /handlers
23+
RUN chmod +x /utilities
2024

2125
ENTRYPOINT ["/entrypoint.sh"]

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2020 Rob Burger
3+
Copyright (c) 2023 Terminus Software
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

0 commit comments

Comments
 (0)