Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run show internally; fix yaml diffs #30

Open
wants to merge 81 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
381ccce
Use intermediate file
jcogilvie Feb 23, 2022
3834131
Revise composite action
jcogilvie Feb 23, 2022
ca59948
Revise composite action
jcogilvie Feb 23, 2022
bc23d9e
Revise composite action
jcogilvie Feb 23, 2022
2e13421
Revise composite action
jcogilvie Feb 23, 2022
47f0ce2
Revise composite action
jcogilvie Feb 23, 2022
75d06ca
Revise composite action
jcogilvie Feb 23, 2022
fa07565
Revise composite action
jcogilvie Feb 23, 2022
aa5d938
Revise composite action
jcogilvie Feb 23, 2022
734988e
Revise composite action
jcogilvie Feb 23, 2022
4d02c2e
Revise composite action
jcogilvie Feb 23, 2022
2e0e19e
Revise composite action
jcogilvie Feb 23, 2022
e7dc9ec
Revise composite action
jcogilvie Feb 23, 2022
cf97a1d
Revise composite action
jcogilvie Feb 23, 2022
936db3c
Revise composite action
jcogilvie Feb 23, 2022
a5743c6
Revise composite action
jcogilvie Feb 23, 2022
8b2cf89
Revise composite action
jcogilvie Feb 23, 2022
198fbf5
Revise composite action
jcogilvie Feb 23, 2022
3fc1049
Revise composite action
jcogilvie Feb 23, 2022
0e63384
Revise composite action
jcogilvie Feb 23, 2022
932864f
Revise composite action
jcogilvie Feb 23, 2022
641c4dd
Revise composite action
jcogilvie Feb 23, 2022
6afa257
Revise composite action
jcogilvie Feb 23, 2022
224153f
Revise composite action
jcogilvie Feb 23, 2022
15a92e0
Revise composite action
jcogilvie Feb 23, 2022
ecaf027
Revise composite action
jcogilvie Feb 23, 2022
a54ef6e
Revise composite action
jcogilvie Feb 23, 2022
472e41a
Revise composite action
jcogilvie Feb 23, 2022
4b22702
Revise composite action
jcogilvie Feb 23, 2022
499e066
Revise composite action
jcogilvie Feb 23, 2022
ad0590a
Revise composite action
jcogilvie Feb 23, 2022
43aea92
Revise composite action
jcogilvie Feb 23, 2022
fe106e8
Revise composite action
jcogilvie Feb 23, 2022
d76066d
Try using filename
jcogilvie Feb 23, 2022
590d946
More verbose logging
jcogilvie Feb 23, 2022
563e54a
More verbose logging
jcogilvie Feb 23, 2022
75332b3
Separate plan from other
jcogilvie Feb 23, 2022
87e8981
Separate plan from other
jcogilvie Feb 23, 2022
4153cd2
Separate plan from other
jcogilvie Feb 23, 2022
944416a
Separate plan from other
jcogilvie Feb 23, 2022
b2d88a2
Separate plan from other
jcogilvie Feb 23, 2022
d9139d8
Separate plan from other
jcogilvie Feb 23, 2022
b065b3b
Separate plan from other
jcogilvie Feb 23, 2022
b835a30
Adjust TF version
jcogilvie Feb 23, 2022
b19afc3
Fix docker syntax
jcogilvie Feb 23, 2022
3bd9531
Fix docker syntax
jcogilvie Feb 23, 2022
3c74b7f
Pass AWS env vars through
jcogilvie Feb 23, 2022
e4a16a5
See if AWS vars are making it
jcogilvie Feb 23, 2022
310bf85
See if AWS vars are making it
jcogilvie Feb 23, 2022
0eb9a0a
See if AWS vars are making it
jcogilvie Feb 23, 2022
cf540bb
Mess with amazon env vars
jcogilvie Feb 24, 2022
916fb69
Don't do terraform show to the console; keep it internal
jcogilvie Feb 24, 2022
8255a4a
Don't show env
jcogilvie Feb 24, 2022
262e222
Merge pull request #1 from GetTerminus/use-intermediate-file
jcogilvie Feb 24, 2022
2536d8e
Adjust branch name in docker build
jcogilvie Feb 24, 2022
b329e59
Update to delete and post multiple comments
jcogilvie Feb 24, 2022
bccc698
Update to delete and post multiple comments
jcogilvie Feb 24, 2022
9514c5b
Fix newline recognition
jcogilvie Feb 24, 2022
57f9f6c
Fix comment contents
jcogilvie Feb 24, 2022
f24d9c5
Fix comment contents
jcogilvie Feb 24, 2022
b0683c9
Merge pull request #2 from GetTerminus/split-plan-comments
jcogilvie Feb 24, 2022
0e4950c
Reference main branch
jcogilvie Feb 24, 2022
a46288a
Merge pull request #3 from GetTerminus/ref-main-branch
jcogilvie Feb 24, 2022
04bb131
Fix yaml diffs (#4)
jcogilvie Feb 25, 2022
bcdf442
Add debug flags (#5)
jcogilvie Mar 2, 2022
06c8f2f
Add new flags to non-plan variant (#6)
jcogilvie Mar 2, 2022
4559d1e
Don't regex replace in the context of '+/-' (#7)
jcogilvie Mar 7, 2022
8e8347e
Fix omit drift (#8)
jcogilvie Apr 14, 2022
1e912c6
Big refactor; add outputs; fix plan failure case (#9)
jcogilvie May 9, 2022
4853d00
Fix style syntax (#10)
jcogilvie May 9, 2022
b043198
feat: add versioning to commenter
dreinhardt89 May 23, 2022
b81ed20
Merge pull request #11 from GetTerminus/dpr-add-versioning
dreinhardt89 May 23, 2022
9e266be
BREAKING: Switch to version v2
dreinhardt89 May 23, 2022
4e91f06
Merge pull request #12 from GetTerminus/dpr-switch-v2
dreinhardt89 May 23, 2022
12c8d87
BREAKING CHANGE: Switch to version v2
dreinhardt89 May 23, 2022
5fe12c2
Merge pull request #13 from GetTerminus/dpr-switch-v2
dreinhardt89 May 23, 2022
e86dd74
Try paginating comments (#14)
jcogilvie Sep 30, 2022
5ccc3c3
feat: add test workflow
dreinhardt89 Jun 17, 2023
18a0ce7
Merge pull request #17 from GetTerminus/add-test-workflow
dreinhardt89 Jun 17, 2023
415fd06
fix: test workflow
dreinhardt89 Jun 21, 2023
67c4b1f
Merge pull request #18 from GetTerminus/dpr-fix-test-workflow
dreinhardt89 Jun 21, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/workflows/release-beta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Release Beta

on:
push:
branches-ignore:
- master

jobs:
release-beta:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set Beta Git tag
uses: weareyipyip/walking-tag-action@v2
with:
tag-name: v2-beta
tag-message: The current beta is based on this commit
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
21 changes: 21 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Release

on:
push:
branches: [ master ]

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Bump version and push tag
id: tag_version
uses: mathieudutour/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
release_branches: "master"
- uses: sersoft-gmbh/running-release-tags-action@v1
with:
tag: ${{ steps.tag_version.outputs.new_tag }}
github-token: ${{secrets.GITHUB_TOKEN}}
79 changes: 79 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Test

on:
workflow_run:
workflows: [Release Beta]
types:
- completed

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TERRAFORM_VERSION: "1.4.6"
TF_WORKSPACE: "testing"
USE_BETA_VERSION: "true"
COMMENTER_DEBUG: "true"
GH_ACCEPT_HEADER: "Accept: application/vnd.github+json"
GH_AUTH_HEADER: "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}"
GH_API_VERSION: "X-GitHub-Api-Version: 2022-11-28"
GH_COMMENT_URL: https://api.github.com/repos/GetTerminus/terraform-pr-commenter/issues/${{ github.event.number }}/comments

jobs:
set-outputs:
name: Set Outputs
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
outputs:
tf_fmt_fail: ${{ steps.file_outputs.outputs.tf_fmt_fail }}
tf_init_fail: ${{ steps.file_outputs.outputs.tf_init_fail }}
tf_plan_fail: ${{ steps.file_outputs.outputs.tf_plan_fail }}
tf_plan_fail_partial: ${{ steps.file_outputs.outputs.tf_plan_fail_partial }}
tf_plan_success_no_changes: ${{ steps.file_outputs.outputs.tf_plan_success_no_changes }}
tf_plan_success_with_changes: ${{ steps.file_outputs.outputs.tf_plan_success_with_changes }}
tf_plan_success_long: ${{ steps.file_outputs.outputs.tf_plan_success_long }}
tf_validate_fail: ${{ steps.file_outputs.outputs.tf_validate_fail }}
strategy:
matrix:
filenames:
- "tf_fmt_fail"
- "tf_init_fail"
- "tf_plan_fail"
- "tf_plan_fail_partial"
- "tf_plan_success_no_changes"
- "tf_plan_success_with_changes"
- "tf_plan_success_long"
- "tf_validate_fail"
steps:
- uses: actions/checkout@v3
- name: Set Test Outputs
id: file_outputs
run: |
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)

#have to truncate so we don't get an "argument list too long" error
if [[ "${{ matrix.filenames }}" == "tf_plan_success_long" ]]; then
OUTPUT=$(cat ./testing/text-files/${{ matrix.filenames }}.txt)
echo "${OUTPUT::130000}" > ./testing/text-files/${{ matrix.filenames }}.txt
fi

echo "${{ matrix.filenames }}<<$EOF" >> $GITHUB_OUTPUT
echo "$(cat ./testing/text-files/${{ matrix.filenames }}.txt)" >> $GITHUB_OUTPUT
echo "$EOF" >> $GITHUB_OUTPUT

# To test other scenarios please change the below variables as necessary.
commenter-test:
name: Test Commenter
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
needs: set-outputs
steps:
- uses: actions/checkout@v3
- name: Test
uses: GetTerminus/terraform-pr-commenter@v3-beta
with:
commenter_type: plan
# Should only be setting commenter_input or commenter_plan_path (commenter_plan_path only for plan commenter type)
#commenter_input: ${{ needs.set-outputs.outputs.tf_plan_fail }}
commenter_plan_path: ./testing/text-files/tf_plan_success_with_changes.txt
commenter_exitcode: 1
terraform_version: ${{ env.TERRAFORM_VERSION }}
use_beta_version: ${{ env.USE_BETA_VERSION }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# IDEs
.idea
.vscode
.DS_Store
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM hashicorp/terraform:1.0.6
ARG TERRAFORM_VERSION=1.0.6
FROM hashicorp/terraform:${TERRAFORM_VERSION}

LABEL repository="https://github.com/robburger/terraform-pr-commenter" \
homepage="https://github.com/robburger/terraform-pr-commenter" \
Expand All @@ -11,6 +12,7 @@ LABEL repository="https://github.com/robburger/terraform-pr-commenter" \
RUN apk add --no-cache -q \
bash \
curl \
perl \
jq

ADD entrypoint.sh /entrypoint.sh
Expand Down
75 changes: 68 additions & 7 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,76 @@ inputs:
description: 'The type of comment. Options: [fmt, init, plan]'
required: true
commenter_input:
description: 'The comment to post from a previous step output'
description: 'The comment to post from a previous step output. Will be trimmed to 64k length.'
required: true
commenter_plan_path:
description: 'The (optional) tfplan file'
required: false
commenter_exitcode:
description: 'The exit code from a previous step output'
required: true
terraform_version:
description: 'The version of terraform with which a plan was generated'
required: false
default: "1.0.6"
use_beta_version:
description: 'Whether to use the beta version of the commenter'
required: false
default: 'false'
runs:
using: 'docker'
image: 'Dockerfile'
args:
- ${{ inputs.commenter_type }}
- ${{ inputs.commenter_input }}
- ${{ inputs.commenter_exitcode }}
using: "composite"
steps:
- name: Build commenter docker image (master)
if: inputs.use_beta_version != 'true'
run: docker build --build-arg TERRAFORM_VERSION=${{ inputs.terraform_version }} -t commenter https://github.com/GetTerminus/terraform-pr-commenter.git#master
shell: bash
- name: Build commenter docker image (beta)
if: inputs.use_beta_version == 'true'
# append branch with a pound (#) if developing. e.g., `commenter.git#my-branch`
run: docker build --build-arg TERRAFORM_VERSION=${{ inputs.terraform_version }} -t commenter https://github.com/GetTerminus/terraform-pr-commenter.git#v2-beta
shell: bash
- name: Run commenter image (plan)
env:
COMMENTER_INPUT: ${{ inputs.commenter_input }}
COMMENTER_PLAN_FILE: ${{ inputs.commenter_plan_path }}
GITHUB_EVENT: ${{ toJSON(github.event) }}
AWS_SECRET_ACCESS_KEY: ${{ env.AWS_SECRET_KEY }}
run: |
COMMENTER_INPUT=${COMMENTER_INPUT::65000}
docker run \
-e GITHUB_TOKEN \
-e TF_WORKSPACE \
-e EXPAND_SUMMARY_DETAILS \
-e HIGHLIGHT_CHANGES \
-e GITHUB_EVENT \
-e COMMENTER_INPUT \
-e AWS_ACCESS_KEY_ID \
-e AWS_SECRET_KEY \
-e AWS_SECRET_ACCESS_KEY \
-e AWS_REGION \
-e COMMENTER_DEBUG \
-e COMMENTER_ECHO \
-e COMMENTER_PLAN_FILE \
-e COMMENTER_POST_PLAN_OUTPUTS \
-v "$(pwd)"/:/workspace \
commenter ${{ inputs.commenter_type }} ${{ inputs.commenter_exitcode }}
shell: bash
if: ${{ inputs.commenter_type == 'plan' }}
- name: Run commenter image (non-plan)
env:
COMMENTER_INPUT: ${{ inputs.commenter_input }}
GITHUB_EVENT: ${{ toJSON(github.event) }}
run: |
docker run \
-e GITHUB_TOKEN \
-e TF_WORKSPACE \
-e EXPAND_SUMMARY_DETAILS \
-e HIGHLIGHT_CHANGES \
-e GITHUB_EVENT \
-e COMMENTER_INPUT \
-e COMMENTER_DEBUG \
-e COMMENTER_ECHO \
commenter ${{ inputs.commenter_type }} ${{ inputs.commenter_exitcode }}
shell: bash
if: ${{ inputs.commenter_type != 'plan' }}

Loading