diff --git a/action.yml b/action.yml
index 6370914a..fbb8d57f 100644
--- a/action.yml
+++ b/action.yml
@@ -29,6 +29,9 @@ inputs:
fmt_enable:
description: Boolean flag to enable TF fmt command and display diff of changes.
default: true
+ plan_outline:
+ description: Boolean flag to output TF plan outline of changes.
+ default: true
recreate_comment:
description: Boolean flag to recreate PR comment on update instead of editing the existing one.
default: true
@@ -258,6 +261,17 @@ runs:
shell: bash
run: ${{ env.TF_CLI_USES }} ${{ steps.arguments.outputs.arg_chdir }} plan -out=tfplan ${{ steps.arguments.outputs.arg_compact_warnings }} ${{ steps.arguments.outputs.arg_concise }} ${{ steps.arguments.outputs.arg_destroy }} ${{ steps.arguments.outputs.arg_lock }} ${{ steps.arguments.outputs.arg_lock_timeout }} ${{ steps.arguments.outputs.arg_parallelism }} ${{ steps.arguments.outputs.arg_refresh }} ${{ steps.arguments.outputs.arg_refresh_only }} ${{ steps.arguments.outputs.arg_replace }} ${{ steps.arguments.outputs.arg_target }} ${{ steps.arguments.outputs.arg_var_file }}
+ # Generate an outline of changes from the TF plan file.
+ - name: TF plan outline
+ if: inputs.plan_outline == 'true'
+ id: plan_outline
+ shell: bash
+ run: ${{ env.TF_CLI_USES }} ${{ steps.arguments.outputs.arg_chdir }} show -no-color tfplan
+
+ - name: Print TF plan outline
+ if: inputs.plan_outline == 'true'
+ run: echo "${{ steps.plan_outline.outputs.stdout }}"
+
# If "-tf=plan" is successful, then upload the TF plan file as a zipped
# repository artifact with a unique identifier for later use.
- name: Upload TF plan file
diff --git a/scripts/comment_tf_output.js b/scripts/comment_tf_output.js
index ac6cab76..6cd5c0f8 100644
--- a/scripts/comment_tf_output.js
+++ b/scripts/comment_tf_output.js
@@ -39,42 +39,39 @@ ${process.env.tf_fmt}
repo: context.repo.repo,
});
- // If [tf] of process.env.tf_command object equals "plan", then parse the TFplan file.
- console.log("process.env.tf_command.tf:", JSON.parse(process.env.tf_command).tf);
-
// Parse the TFplan file to create an outline of changes.
let comment_outline = "";
- if (JSON.parse(process.env.tf_command).tf === "plan") {
- // Parse TFplan file.
- let tfplan = "";
- const data_handler = (data) => {
- tfplan += data.toString();
- };
- const options = {
- listeners: {
- stdout: data_handler,
- stderr: data_handler,
- },
- };
- await exec.exec(process.env.TF_CLI, [`-chdir=${process.env.TF_CHDIR}`, "show", "-no-color", "tfplan"], options);
-
- // Create an outline from lines starting with ' # ' while removing the prefix for the first 12000 characters.
- const changed_lines = tfplan
- .split("\n")
- .filter((line) => line.startsWith(" # "))
- .map((line) => line.slice(4))
- .slice(0, 12000);
-
- // Display the TFplan outline.
- comment_outline = `
-Outline of changes.
-
-\`\`\`hcl
-${changed_lines.join("\n")}
-\`\`\`
-
-`;
- }
+// if (JSON.parse(process.env.tf_command).tf === "plan") {
+// // Parse TFplan file.
+// let tfplan = "";
+// const data_handler = (data) => {
+// tfplan += data.toString();
+// };
+// const options = {
+// listeners: {
+// stdout: data_handler,
+// stderr: data_handler,
+// },
+// };
+// await exec.exec(process.env.TF_CLI, [`-chdir=${process.env.TF_CHDIR}`, "show", "-no-color", "tfplan"], options);
+
+// // Create an outline from lines starting with ' # ' while removing the prefix for the first 12000 characters.
+// const changed_lines = tfplan
+// .split("\n")
+// .filter((line) => line.startsWith(" # "))
+// .map((line) => line.slice(4))
+// .slice(0, 12000);
+
+// // Display the TFplan outline.
+// comment_outline = `
+// Outline of changes.
+
+// \`\`\`hcl
+// ${changed_lines.join("\n")}
+// \`\`\`
+//
+// `;
+// }
// Display the: TF command, TF output, and workflow authorip.
const comment_output = `