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" diff --git a/Dockerfile b/Dockerfile index d6741783..5d09ed39 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM hashicorp/terraform:1.0.6 +FROM hashicorp/terraform:1.5.7 LABEL repository="https://github.com/robburger/terraform-pr-commenter" \ homepage="https://github.com/robburger/terraform-pr-commenter" \ 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 \`\`\`