From 1ad1a1584f2193922ca71a7db00b081d77327ca3 Mon Sep 17 00:00:00 2001 From: Heiko Voigt Date: Thu, 20 Apr 2023 15:18:46 +0200 Subject: [PATCH 1/4] update terraform base image This should fix a curl error: Error relocating /usr/bin/curl: curl_easy_header: symbol not found --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index d6741783..4b77d833 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM hashicorp/terraform:1.0.6 +FROM hashicorp/terraform:1.4.5 LABEL repository="https://github.com/robburger/terraform-pr-commenter" \ homepage="https://github.com/robburger/terraform-pr-commenter" \ From 7cd0700a6bbc8ff16e568c299611debe651ed03a Mon Sep 17 00:00:00 2001 From: Heiko Voigt Date: Thu, 23 Jun 2022 16:40:50 +0200 Subject: [PATCH 2/4] add possibility for an optional PR comment comment This is useful if you e.g. have multiple terraform plan runs and you want to add a hint which one this is. --- README.md | 1 + action.yml | 5 +++++ entrypoint.sh | 17 ++++++++++------- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index a51a1b4b..eb442a59 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,7 @@ This action can only be run after a Terraform `fmt`, `init`, `plan` or `validate | `commenter_type` | _required_ | The type of comment. Options: [`fmt`, `init`, `plan`, `validate`] | | `commenter_input` | _required_ | The comment to post from a previous step output. | | `commenter_exitcode` | _required_ | The exit code from a previous step output. | +| `commenter_comment` | _optional_ | An optional comment to add to the end of the headline. | ### Environment Variables diff --git a/action.yml b/action.yml index ea2f2464..3f64e2f2 100644 --- a/action.yml +++ b/action.yml @@ -14,6 +14,10 @@ inputs: commenter_exitcode: description: 'The exit code from a previous step output' required: true + commenter_comment: + description: 'An optional comment to add to the headline.' + required: false + default: '' runs: using: 'docker' image: 'Dockerfile' @@ -21,3 +25,4 @@ runs: - ${{ inputs.commenter_type }} - ${{ inputs.commenter_input }} - ${{ inputs.commenter_exitcode }} + - ${{ inputs.commenter_comment }} diff --git a/entrypoint.sh b/entrypoint.sh index 1f71f2c8..bf1ae162 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -24,6 +24,8 @@ if [[ ! "$1" =~ ^(fmt|init|plan|validate)$ ]]; then exit 1 fi +comment="$4" + ################## # Shared Variables ################## @@ -82,7 +84,7 @@ if [[ $COMMAND == 'fmt' ]]; then # Meaning: 1 = Malformed Terraform CLI command. 2 = Terraform parse error. # Actions: Build PR comment. if [[ $EXIT_CODE -eq 1 || $EXIT_CODE -eq 2 ]]; then - PR_COMMENT="### Terraform \`fmt\` Failed + PR_COMMENT="### Terraform \`fmt\` Failed $comment Show Output \`\`\` @@ -107,7 +109,7 @@ $THIS_FILE_DIFF " done - PR_COMMENT="### Terraform \`fmt\` Failed + PR_COMMENT="### Terraform \`fmt\` Failed $comment $ALL_FILES_DIFF" fi @@ -147,7 +149,7 @@ if [[ $COMMAND == 'init' ]]; then # Meaning: Terraform initialize failed or malformed Terraform CLI command. # Actions: Build PR comment. if [[ $EXIT_CODE -eq 1 ]]; then - PR_COMMENT="### Terraform \`init\` Failed + PR_COMMENT="### Terraform \`init\` Failed $comment Show Output \`\`\` @@ -170,7 +172,8 @@ fi if [[ $COMMAND == 'plan' ]]; then # Look for an existing plan PR comment and delete echo -e "\033[34;1mINFO:\033[0m Looking for an existing plan PR comment." - PR_COMMENT_ID=$(curl -sS -H "$AUTH_HEADER" -H "$ACCEPT_HEADER" -L "$PR_COMMENTS_URL" | jq '.[] | select(.body|test ("### Terraform `plan` .* for Workspace: `'"$WORKSPACE"'`")) | .id') + PR_COMMENT_ID=$(curl -sS -H "$AUTH_HEADER" -H "$ACCEPT_HEADER" -L "$PR_COMMENTS_URL" | + jq '.[] | select(.body|test ("### Terraform `plan` .* for Workspace: `'"$WORKSPACE"'` '"$comment"'")) | .id') if [ "$PR_COMMENT_ID" ]; then echo -e "\033[34;1mINFO:\033[0m Found existing plan PR comment: $PR_COMMENT_ID. Deleting." PR_COMMENT_URL="$PR_COMMENT_URI/$PR_COMMENT_ID" @@ -190,7 +193,7 @@ if [[ $COMMAND == 'plan' ]]; then if [[ $COLOURISE == 'true' ]]; then CLEAN_PLAN=$(echo "$CLEAN_PLAN" | sed -r 's/^~/!/g') # Replace ~ with ! to colourise the diff in GitHub comments fi - PR_COMMENT="### Terraform \`plan\` Succeeded for Workspace: \`$WORKSPACE\` + PR_COMMENT="### Terraform \`plan\` Succeeded for Workspace: \`$WORKSPACE\` $comment Show Output \`\`\`diff @@ -203,7 +206,7 @@ $CLEAN_PLAN # Meaning: Terraform plan failed. # Actions: Build PR comment. if [[ $EXIT_CODE -eq 1 ]]; then - PR_COMMENT="### Terraform \`plan\` Failed for Workspace: \`$WORKSPACE\` + PR_COMMENT="### Terraform \`plan\` Failed for Workspace: \`$WORKSPACE\` $comment Show Output \`\`\` @@ -248,7 +251,7 @@ if [[ $COMMAND == 'validate' ]]; then # Meaning: Terraform validate failed or malformed Terraform CLI command. # Actions: Build PR comment. if [[ $EXIT_CODE -eq 1 ]]; then - PR_COMMENT="### Terraform \`validate\` Failed + PR_COMMENT="### Terraform \`validate\` Failed $comment Show Output \`\`\` From d7e0c849dd66ad0f2df096f69a421f80b4e6cfc3 Mon Sep 17 00:00:00 2001 From: Heiko Voigt <184958+hvoigt@users.noreply.github.com> Date: Tue, 26 Sep 2023 08:41:46 +0200 Subject: [PATCH 3/4] Create dependabot.yml --- .github/dependabot.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..53bf9576 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,11 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates + +version: 2 +updates: + - package-ecosystem: "docker" # See documentation for possible values + directory: "/" # Location of package manifests + schedule: + interval: "weekly" From ae7752c76269be0145701590000893075787cb6b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 26 Sep 2023 06:42:03 +0000 Subject: [PATCH 4/4] Bump hashicorp/terraform from 1.4.5 to 1.5.7 Bumps hashicorp/terraform from 1.4.5 to 1.5.7. --- updated-dependencies: - dependency-name: hashicorp/terraform dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 4b77d833..5d09ed39 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM hashicorp/terraform:1.4.5 +FROM hashicorp/terraform:1.5.7 LABEL repository="https://github.com/robburger/terraform-pr-commenter" \ homepage="https://github.com/robburger/terraform-pr-commenter" \