From a79eab979bd42cb712629d5db9255018729f56a7 Mon Sep 17 00:00:00 2001 From: Rishav Dhar <19497993+rdhar@users.noreply.github.com> Date: Tue, 25 Jun 2024 15:02:12 +0100 Subject: [PATCH 1/4] remove deprovision steps for simplicity --- .github/workflows/tf_sample.yaml | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/.github/workflows/tf_sample.yaml b/.github/workflows/tf_sample.yaml index b515f39e..90e09ed8 100644 --- a/.github/workflows/tf_sample.yaml +++ b/.github/workflows/tf_sample.yaml @@ -48,17 +48,6 @@ jobs: command_input: ${{ format('-tf={0} -chdir=stacks/sample_instance -var-file=env/{1}.tfvars', github.event.action != 'closed' && 'plan -lock=false' || 'apply', matrix.context) }} cache_plugins: false - - name: Await resource initialization - if: github.event.action == 'closed' - run: sleep 150 - - - name: Deprovision TF - if: github.event.action == 'closed' - uses: ./ - with: - command_input: -tf=apply -chdir=stacks/sample_instance -var-file=env/${{ matrix.context }}.tfvars -destroy -auto-approve - cache_plugins: false - Bucket: runs-on: ubuntu-latest if: github.event.action != 'closed' || github.event.pull_request.merged @@ -88,14 +77,3 @@ jobs: with: command_input: ${{ format('-tf={0} -chdir=stacks/sample_bucket -backend-config=backend/{1}.tfbackend', github.event.action != 'closed' && 'plan -lock=false' || 'apply', matrix.context) }} cache_plugins: false - - - name: Await resource initialization - if: github.event.action == 'closed' - run: sleep 150 - - - name: Deprovision TF - if: github.event.action == 'closed' - uses: ./ - with: - command_input: -tf=apply -chdir=stacks/sample_bucket -backend-config=backend/${{ matrix.context }}.tfbackend -destroy -auto-approve - cache_plugins: false From 645c3975c6888e98dc4448eae81b8aba7749de84 Mon Sep 17 00:00:00 2001 From: Rishav Dhar <19497993+rdhar@users.noreply.github.com> Date: Tue, 25 Jun 2024 15:12:40 +0100 Subject: [PATCH 2/4] fix diff indicator matching --- scripts/comment_tf_output.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/comment_tf_output.js b/scripts/comment_tf_output.js index 19b01c3e..157b906b 100644 --- a/scripts/comment_tf_output.js +++ b/scripts/comment_tf_output.js @@ -62,9 +62,9 @@ ${process.env.tf_fmt} .filter(line => line.startsWith(" # ")) .map(line => { const diff_line = line.slice(4); - if (diff_line.includes("create")) return "+ " + diff_line; - if (diff_line.includes("update")) return "! " + diff_line; - if (diff_line.includes("delete")) return "- " + diff_line; + if (diff_line.includes(" created")) return "+ " + diff_line; + if (diff_line.includes(" updated")) return "! " + diff_line; + if (diff_line.includes(" destroyed")) return "- " + diff_line; return diff_line; }); From 6fd9613c2a939a4d977297a4a47a6edad8a5d16c Mon Sep 17 00:00:00 2001 From: Rishav Dhar <19497993+rdhar@users.noreply.github.com> Date: Tue, 25 Jun 2024 15:21:53 +0100 Subject: [PATCH 3/4] account for "has been" change type --- scripts/comment_tf_output.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/comment_tf_output.js b/scripts/comment_tf_output.js index 157b906b..37786e76 100644 --- a/scripts/comment_tf_output.js +++ b/scripts/comment_tf_output.js @@ -63,8 +63,9 @@ ${process.env.tf_fmt} .map(line => { const diff_line = line.slice(4); if (diff_line.includes(" created")) return "+ " + diff_line; - if (diff_line.includes(" updated")) return "! " + diff_line; if (diff_line.includes(" destroyed")) return "- " + diff_line; + if (diff_line.includes(" updated")) return "! " + diff_line; + if (diff_line.includes(" has been")) return "# " + diff_line; return diff_line; }); From a990dda969c36995b6e4ba8129318725ba95bdae Mon Sep 17 00:00:00 2001 From: Rishav Dhar <19497993+rdhar@users.noreply.github.com> Date: Tue, 25 Jun 2024 15:25:29 +0100 Subject: [PATCH 4/4] format js --- scripts/comment_tf_output.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/comment_tf_output.js b/scripts/comment_tf_output.js index 37786e76..cdeb04d7 100644 --- a/scripts/comment_tf_output.js +++ b/scripts/comment_tf_output.js @@ -59,13 +59,13 @@ ${process.env.tf_fmt} // Re-prefix the lines with diff indicators based on the change type. const changed_lines = tfplan .split("\n") - .filter(line => line.startsWith(" # ")) - .map(line => { + .filter((line) => line.startsWith(" # ")) + .map((line) => { const diff_line = line.slice(4); if (diff_line.includes(" created")) return "+ " + diff_line; if (diff_line.includes(" destroyed")) return "- " + diff_line; if (diff_line.includes(" updated")) return "! " + diff_line; - if (diff_line.includes(" has been")) return "# " + diff_line; + if (diff_line.includes(" been")) return "# " + diff_line; return diff_line; });