From 03db5460e50d18f852f66278626a36840ecd061b Mon Sep 17 00:00:00 2001 From: Zinovii Dmytriv Date: Tue, 8 Aug 2023 12:32:35 +0300 Subject: [PATCH 01/61] update --- action.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/action.yml b/action.yml index e723e3b00..82d87957c 100644 --- a/action.yml +++ b/action.yml @@ -55,6 +55,13 @@ inputs: not supplied by the user. When running this action on github.com, the default value is sufficient. When running on GHES, you can pass a personal access token for github.com if you are experiencing rate limiting. default: ${{ github.server_url == 'https://github.com' && github.token || '' }} +outputs: + plan-file-path: + description: Plan File + value: ${{ steps.atmos-plan.outputs.plan_file_path }} + plan-file: + description: Plan File + value: ${{ steps.atmos-plan.outputs.plan_file }} runs: using: "composite" From 8dba22d04090f556e95503c3d04ee74bd9d5b717 Mon Sep 17 00:00:00 2001 From: Zinovii Dmytriv Date: Wed, 9 Aug 2023 13:58:29 +0300 Subject: [PATCH 02/61] update --- action.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 82d87957c..e97d448ac 100644 --- a/action.yml +++ b/action.yml @@ -14,6 +14,10 @@ inputs: component-path: description: "The path to the base component. Atmos defines this value as component_path." required: true + sha: + description: "Commit SHA that will be used as suffix for plan file" + required: true + default: ${{ github.sha }} terraform-plan-role: description: "The AWS role to be used to plan Terraform." required: true @@ -127,7 +131,7 @@ runs: id: atmos-plan shell: bash run: | - PLAN_FILE=$(echo "${{ inputs.stack }}-${{ inputs.component }}-${{github.sha}}.planfile" | sed 's#/#_#g') + PLAN_FILE=$(echo "${{ inputs.stack }}-${{ inputs.component }}-${{input.sha}}.planfile" | sed 's#/#_#g') PLAN_FILE_PATH=$(pwd) ATMOS_BASE_PATH=$GITHUB_WORKSPACE atmos terraform plan ${{ inputs.component }} \ --stack ${{ inputs.stack }} \ From bfc926c5f92f862e5245cedc20c42753f9859ea0 Mon Sep 17 00:00:00 2001 From: Zinovii Dmytriv Date: Wed, 9 Aug 2023 14:05:04 +0300 Subject: [PATCH 03/61] update --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index e97d448ac..8dcff0522 100644 --- a/action.yml +++ b/action.yml @@ -131,7 +131,7 @@ runs: id: atmos-plan shell: bash run: | - PLAN_FILE=$(echo "${{ inputs.stack }}-${{ inputs.component }}-${{input.sha}}.planfile" | sed 's#/#_#g') + PLAN_FILE=$(echo "${{ inputs.stack }}-${{ inputs.component }}-${{inputs.sha}}.planfile" | sed 's#/#_#g') PLAN_FILE_PATH=$(pwd) ATMOS_BASE_PATH=$GITHUB_WORKSPACE atmos terraform plan ${{ inputs.component }} \ --stack ${{ inputs.stack }} \ From 51028a5ec3ef3e48d77e0521a0c8a57b175ba41b Mon Sep 17 00:00:00 2001 From: Zinovii Dmytriv Date: Wed, 9 Aug 2023 15:34:25 +0300 Subject: [PATCH 04/61] update --- action.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/action.yml b/action.yml index 8dcff0522..fc1a1adcc 100644 --- a/action.yml +++ b/action.yml @@ -14,8 +14,8 @@ inputs: component-path: description: "The path to the base component. Atmos defines this value as component_path." required: true - sha: - description: "Commit SHA that will be used as suffix for plan file" + plan-file-suffix: + description: "Suffix that is used to build plan file name. Default: '${{ github.sha }}'" required: true default: ${{ github.sha }} terraform-plan-role: @@ -131,7 +131,7 @@ runs: id: atmos-plan shell: bash run: | - PLAN_FILE=$(echo "${{ inputs.stack }}-${{ inputs.component }}-${{inputs.sha}}.planfile" | sed 's#/#_#g') + PLAN_FILE=$(echo "${{ inputs.stack }}-${{ inputs.component }}-${{ inputs.plan-file-suffix }}.planfile" | sed 's#/#_#g') PLAN_FILE_PATH=$(pwd) ATMOS_BASE_PATH=$GITHUB_WORKSPACE atmos terraform plan ${{ inputs.component }} \ --stack ${{ inputs.stack }} \ From 0760bdbc2dc0e209eb939561dff79b851616212a Mon Sep 17 00:00:00 2001 From: Zinovii Dmytriv Date: Wed, 9 Aug 2023 15:46:22 +0300 Subject: [PATCH 05/61] update --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index fc1a1adcc..c06ee95e3 100644 --- a/action.yml +++ b/action.yml @@ -17,7 +17,7 @@ inputs: plan-file-suffix: description: "Suffix that is used to build plan file name. Default: '${{ github.sha }}'" required: true - default: ${{ github.sha }} + default: "${{ github.sha }}" terraform-plan-role: description: "The AWS role to be used to plan Terraform." required: true From c4ca3d23a1e1a8109ff354b67a9f9b08cfd3c6cd Mon Sep 17 00:00:00 2001 From: Zinovii Dmytriv Date: Wed, 9 Aug 2023 15:51:22 +0300 Subject: [PATCH 06/61] update --- action.yml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/action.yml b/action.yml index c06ee95e3..ab071fa09 100644 --- a/action.yml +++ b/action.yml @@ -15,9 +15,9 @@ inputs: description: "The path to the base component. Atmos defines this value as component_path." required: true plan-file-suffix: - description: "Suffix that is used to build plan file name. Default: '${{ github.sha }}'" - required: true - default: "${{ github.sha }}" + description: "Suffix that is used to build plan file name. Default: ''" + required: false + default: "" terraform-plan-role: description: "The AWS role to be used to plan Terraform." required: true @@ -131,7 +131,12 @@ runs: id: atmos-plan shell: bash run: | - PLAN_FILE=$(echo "${{ inputs.stack }}-${{ inputs.component }}-${{ inputs.plan-file-suffix }}.planfile" | sed 's#/#_#g') + SUFFIX="${{ github.sha }}" + if [ "$variable" != "" ]; then + SUFFIX="${{ inputs.plan-file-suffix }}" + fi + + PLAN_FILE=$(echo "${{ inputs.stack }}-${{ inputs.component }}-${SUFFIX}.planfile" | sed 's#/#_#g') PLAN_FILE_PATH=$(pwd) ATMOS_BASE_PATH=$GITHUB_WORKSPACE atmos terraform plan ${{ inputs.component }} \ --stack ${{ inputs.stack }} \ From 758d7f6106ea739807638066843d46d280d4f593 Mon Sep 17 00:00:00 2001 From: Zinovii Dmytriv Date: Wed, 9 Aug 2023 16:22:29 +0300 Subject: [PATCH 07/61] update --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index ab071fa09..7e7e192fb 100644 --- a/action.yml +++ b/action.yml @@ -132,7 +132,7 @@ runs: shell: bash run: | SUFFIX="${{ github.sha }}" - if [ "$variable" != "" ]; then + if [ "${{ inputs.plan-file-suffix }}" != "" ]; then SUFFIX="${{ inputs.plan-file-suffix }}" fi From f25a90928b56c7cf83b798cdc34262e5fd8cb63d Mon Sep 17 00:00:00 2001 From: Zinovii Dmytriv Date: Wed, 9 Aug 2023 16:41:26 +0300 Subject: [PATCH 08/61] update --- action.yml | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/action.yml b/action.yml index 7e7e192fb..f45d23dab 100644 --- a/action.yml +++ b/action.yml @@ -14,10 +14,10 @@ inputs: component-path: description: "The path to the base component. Atmos defines this value as component_path." required: true - plan-file-suffix: - description: "Suffix that is used to build plan file name. Default: ''" + plan-file: + description: "Full name of the plan-file to use. If not set plan-file name will be built by pattern '--'. Default: ''" required: false - default: "" + default: '' terraform-plan-role: description: "The AWS role to be used to plan Terraform." required: true @@ -131,12 +131,11 @@ runs: id: atmos-plan shell: bash run: | - SUFFIX="${{ github.sha }}" - if [ "${{ inputs.plan-file-suffix }}" != "" ]; then - SUFFIX="${{ inputs.plan-file-suffix }}" + PLAN_FILE=$(echo "${{ inputs.stack }}-${{ inputs.component }}-${{ github.sha }}.planfile" | sed 's#/#_#g') + if [ "${{ inputs.plan-file }}" != "" ]; then + PLAN_FILE="${{ inputs.plan-file }}" fi - PLAN_FILE=$(echo "${{ inputs.stack }}-${{ inputs.component }}-${SUFFIX}.planfile" | sed 's#/#_#g') PLAN_FILE_PATH=$(pwd) ATMOS_BASE_PATH=$GITHUB_WORKSPACE atmos terraform plan ${{ inputs.component }} \ --stack ${{ inputs.stack }} \ From e029db4eeaabbf5c8f478051146c670778a0cfff Mon Sep 17 00:00:00 2001 From: Zinovii Dmytriv Date: Wed, 9 Aug 2023 18:34:31 +0300 Subject: [PATCH 09/61] update --- action.yml | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/action.yml b/action.yml index f45d23dab..f12dc94ba 100644 --- a/action.yml +++ b/action.yml @@ -103,6 +103,7 @@ runs: else echo "actions_enabled=false" >> $GITHUB_OUTPUT fi + echo "HAS_CHANGES=true" >> $GITHUB_ENV # setup-tfcmt requires this PATH update when running on self-hosted (amazon linux) # https://github.com/shmokmt/actions-setup-tfcmt/blob/main/action.yml#L11C1-L12C1 @@ -144,8 +145,20 @@ runs: echo "plan_file=$PLAN_FILE" >> $GITHUB_OUTPUT echo "plan_file_path=$PLAN_FILE_PATH" >> $GITHUB_OUTPUT - - name: Configure State AWS Credentials + - name: Plan Has Changes if: ${{ fromJSON(steps.settings.outputs.actions_enabled) }} + id: plan-state + shell: bash + run: | + terraform show -json "${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }}" > "${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }}.json" + HAS_CHANGES=$(jq '.resource_changes[] | select(.change.actions[] != "no-op")' "${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }}.json") + + if [[ "$HAS_CHANGES" == "" ]]; then + echo "HAS_CHANGES=false" >> $GITHUB_ENV + fi + + - name: Configure State AWS Credentials + if: ${{ fromJSON(env.HAS_CHANGES) }} uses: aws-actions/configure-aws-credentials@v2.2.0 with: aws-region: ${{ inputs.aws-region }} @@ -154,7 +167,7 @@ runs: mask-aws-account-id: "no" - name: Store Plan - if: ${{ fromJSON(steps.settings.outputs.actions_enabled) }} + if: ${{ fromJSON(env.HAS_CHANGES) }} uses: cloudposse/github-action-terraform-plan-storage@v1 id: store-plan with: @@ -166,7 +179,7 @@ runs: bucketName: ${{ inputs.terraform-state-bucket }} - name: Store Lockfile - if: ${{ fromJSON(steps.settings.outputs.actions_enabled) }} + if: ${{ fromJSON(env.HAS_CHANGES) }} uses: cloudposse/github-action-terraform-plan-storage@v1 with: action: storePlan @@ -177,13 +190,13 @@ runs: bucketName: ${{ inputs.terraform-state-bucket }} - name: Setup Infracost - if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(inputs.enable-infracost) }} + if: ${{ fromJSON(env.HAS_CHANGES) && fromJSON(inputs.enable-infracost) }} uses: infracost/actions/setup@v2 with: api-key: ${{ inputs.infracost-api-key }} - name: Generate Infracost diff - if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(inputs.enable-infracost) }} + if: ${{ fromJSON(env.HAS_CHANGES) && fromJSON(inputs.enable-infracost) }} shell: bash run: | PLAN_FILE="${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }}" @@ -203,7 +216,7 @@ runs: --project-name ${{ inputs.stack }}-${{ inputs.component }} \ --out-file=/tmp/infracost.json - - if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(inputs.enable-infracost) && fromJSON(inputs.debug) }} + - if: ${{ fromJSON(env.HAS_CHANGES) && fromJSON(inputs.enable-infracost) && fromJSON(inputs.debug) }} shell: bash run: | cat ${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }}.json @@ -211,7 +224,7 @@ runs: cat /tmp/infracost.json - name: Set infracost variables - if: ${{ fromJSON(steps.settings.outputs.actions_enabled) }} + if: ${{ fromJSON(env.HAS_CHANGES) }} id: infracost-diff shell: bash run: | @@ -227,7 +240,7 @@ runs: echo "infracost_diff_total_monthly_cost=$INFRACOST_DIFF_TOTAL_MONTHLY_COST" >> "$GITHUB_OUTPUT" - name: Post Plan - if: ${{ fromJSON(steps.settings.outputs.actions_enabled) }} + if: ${{ fromJSON(env.HAS_CHANGES) }} id: post-plan shell: bash run: | From 2d19d9d7a8a470133876b29d50fe958eedc456b5 Mon Sep 17 00:00:00 2001 From: Zinovii Dmytriv Date: Wed, 9 Aug 2023 18:42:40 +0300 Subject: [PATCH 10/61] update --- action.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/action.yml b/action.yml index f12dc94ba..f02cce8a3 100644 --- a/action.yml +++ b/action.yml @@ -158,7 +158,7 @@ runs: fi - name: Configure State AWS Credentials - if: ${{ fromJSON(env.HAS_CHANGES) }} + if: env.HAS_CHANGES == 'true' uses: aws-actions/configure-aws-credentials@v2.2.0 with: aws-region: ${{ inputs.aws-region }} @@ -167,7 +167,7 @@ runs: mask-aws-account-id: "no" - name: Store Plan - if: ${{ fromJSON(env.HAS_CHANGES) }} + if: env.HAS_CHANGES == 'true' uses: cloudposse/github-action-terraform-plan-storage@v1 id: store-plan with: @@ -179,7 +179,7 @@ runs: bucketName: ${{ inputs.terraform-state-bucket }} - name: Store Lockfile - if: ${{ fromJSON(env.HAS_CHANGES) }} + if: env.HAS_CHANGES == 'true' uses: cloudposse/github-action-terraform-plan-storage@v1 with: action: storePlan @@ -190,13 +190,13 @@ runs: bucketName: ${{ inputs.terraform-state-bucket }} - name: Setup Infracost - if: ${{ fromJSON(env.HAS_CHANGES) && fromJSON(inputs.enable-infracost) }} + if: ${{ env.HAS_CHANGES == 'true' && fromJSON(inputs.enable-infracost) }} uses: infracost/actions/setup@v2 with: api-key: ${{ inputs.infracost-api-key }} - name: Generate Infracost diff - if: ${{ fromJSON(env.HAS_CHANGES) && fromJSON(inputs.enable-infracost) }} + if: ${{ env.HAS_CHANGES == 'true' && fromJSON(inputs.enable-infracost) }} shell: bash run: | PLAN_FILE="${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }}" @@ -216,7 +216,7 @@ runs: --project-name ${{ inputs.stack }}-${{ inputs.component }} \ --out-file=/tmp/infracost.json - - if: ${{ fromJSON(env.HAS_CHANGES) && fromJSON(inputs.enable-infracost) && fromJSON(inputs.debug) }} + - if: ${{ env.HAS_CHANGES == 'true' && fromJSON(inputs.enable-infracost) && fromJSON(inputs.debug) }} shell: bash run: | cat ${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }}.json @@ -224,7 +224,7 @@ runs: cat /tmp/infracost.json - name: Set infracost variables - if: ${{ fromJSON(env.HAS_CHANGES) }} + if: env.HAS_CHANGES == 'true' id: infracost-diff shell: bash run: | @@ -240,7 +240,7 @@ runs: echo "infracost_diff_total_monthly_cost=$INFRACOST_DIFF_TOTAL_MONTHLY_COST" >> "$GITHUB_OUTPUT" - name: Post Plan - if: ${{ fromJSON(env.HAS_CHANGES) }} + if: env.HAS_CHANGES == 'true' id: post-plan shell: bash run: | From e311916bd1b65538bc82bfe919002e124c3c3cf2 Mon Sep 17 00:00:00 2001 From: Zinovii Dmytriv Date: Wed, 9 Aug 2023 18:45:12 +0300 Subject: [PATCH 11/61] update --- action.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/action.yml b/action.yml index f02cce8a3..82a7f7601 100644 --- a/action.yml +++ b/action.yml @@ -151,12 +151,18 @@ runs: shell: bash run: | terraform show -json "${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }}" > "${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }}.json" + echo "here1" HAS_CHANGES=$(jq '.resource_changes[] | select(.change.actions[] != "no-op")' "${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }}.json") + echo "here2" if [[ "$HAS_CHANGES" == "" ]]; then + echo "here3" echo "HAS_CHANGES=false" >> $GITHUB_ENV + echo "here4" fi + echo "here5" + - name: Configure State AWS Credentials if: env.HAS_CHANGES == 'true' uses: aws-actions/configure-aws-credentials@v2.2.0 From 3a788d77306dfd9cf1ef50c8b9d315aef34df0a2 Mon Sep 17 00:00:00 2001 From: Zinovii Dmytriv Date: Wed, 9 Aug 2023 18:47:08 +0300 Subject: [PATCH 12/61] update --- action.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/action.yml b/action.yml index 82a7f7601..8005481b6 100644 --- a/action.yml +++ b/action.yml @@ -150,6 +150,7 @@ runs: id: plan-state shell: bash run: | + echo "here0" terraform show -json "${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }}" > "${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }}.json" echo "here1" HAS_CHANGES=$(jq '.resource_changes[] | select(.change.actions[] != "no-op")' "${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }}.json") From bc60da77fc6cfd700b4fa5680a0cfa4f8386b756 Mon Sep 17 00:00:00 2001 From: Zinovii Dmytriv Date: Wed, 9 Aug 2023 18:49:17 +0300 Subject: [PATCH 13/61] update --- action.yml | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/action.yml b/action.yml index 8005481b6..d722dc717 100644 --- a/action.yml +++ b/action.yml @@ -150,20 +150,18 @@ runs: id: plan-state shell: bash run: | - echo "here0" - terraform show -json "${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }}" > "${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }}.json" - echo "here1" + PLAN_FILE="${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }}" + PLAN_FILE_JSON="${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }}.json" + + cd ${{ inputs.component-path }} + terraform show -json $PLAN_FILE > $PLAN_FILE_JSON + HAS_CHANGES=$(jq '.resource_changes[] | select(.change.actions[] != "no-op")' "${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }}.json") - echo "here2" if [[ "$HAS_CHANGES" == "" ]]; then - echo "here3" echo "HAS_CHANGES=false" >> $GITHUB_ENV - echo "here4" fi - echo "here5" - - name: Configure State AWS Credentials if: env.HAS_CHANGES == 'true' uses: aws-actions/configure-aws-credentials@v2.2.0 @@ -206,7 +204,6 @@ runs: if: ${{ env.HAS_CHANGES == 'true' && fromJSON(inputs.enable-infracost) }} shell: bash run: | - PLAN_FILE="${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }}" PLAN_FILE_JSON="${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }}.json" cd ${{ inputs.component-path }} From 2fdb804d9cdad861013e3c163e295c858eabed64 Mon Sep 17 00:00:00 2001 From: Zinovii Dmytriv Date: Wed, 9 Aug 2023 18:52:17 +0300 Subject: [PATCH 14/61] update --- action.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/action.yml b/action.yml index d722dc717..40afe94f1 100644 --- a/action.yml +++ b/action.yml @@ -150,10 +150,15 @@ runs: id: plan-state shell: bash run: | + ls -l + pwd + PLAN_FILE="${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }}" PLAN_FILE_JSON="${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }}.json" cd ${{ inputs.component-path }} + ls -l + pwd terraform show -json $PLAN_FILE > $PLAN_FILE_JSON HAS_CHANGES=$(jq '.resource_changes[] | select(.change.actions[] != "no-op")' "${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }}.json") From 982a4e2481477e665ee48a824498fb56f7ca6100 Mon Sep 17 00:00:00 2001 From: Zinovii Dmytriv Date: Wed, 9 Aug 2023 18:54:51 +0300 Subject: [PATCH 15/61] update --- action.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/action.yml b/action.yml index 40afe94f1..c44603b8f 100644 --- a/action.yml +++ b/action.yml @@ -156,12 +156,15 @@ runs: PLAN_FILE="${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }}" PLAN_FILE_JSON="${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }}.json" - cd ${{ inputs.component-path }} - ls -l - pwd + echo $PLAN_FILE + echo $PLAN_FILE_JSON + terraform show -json $PLAN_FILE > $PLAN_FILE_JSON + cat $PLAN_FILE_JSON | jq . + HAS_CHANGES=$(jq '.resource_changes[] | select(.change.actions[] != "no-op")' "${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }}.json") + echo "HAS_CHANGES=$HAS_CHANGES" if [[ "$HAS_CHANGES" == "" ]]; then echo "HAS_CHANGES=false" >> $GITHUB_ENV From 5dd0740fc8de20f51a8de41870985383e32aa8bb Mon Sep 17 00:00:00 2001 From: Zinovii Dmytriv Date: Wed, 9 Aug 2023 18:57:06 +0300 Subject: [PATCH 16/61] update --- action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index c44603b8f..19ba7a290 100644 --- a/action.yml +++ b/action.yml @@ -153,8 +153,8 @@ runs: ls -l pwd - PLAN_FILE="${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }}" - PLAN_FILE_JSON="${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }}.json" + PLAN_FILE="${{ steps.atmos-plan.outputs.plan_file }}" + PLAN_FILE_JSON="${{ steps.atmos-plan.outputs.plan_file }}.json" echo $PLAN_FILE echo $PLAN_FILE_JSON From 6c4749d9cb8d25756d736dd37d111b7118a04190 Mon Sep 17 00:00:00 2001 From: Zinovii Dmytriv Date: Wed, 9 Aug 2023 19:04:04 +0300 Subject: [PATCH 17/61] update --- action.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/action.yml b/action.yml index 19ba7a290..9da1cbee6 100644 --- a/action.yml +++ b/action.yml @@ -150,20 +150,20 @@ runs: id: plan-state shell: bash run: | - ls -l - pwd + set -ex - PLAN_FILE="${{ steps.atmos-plan.outputs.plan_file }}" - PLAN_FILE_JSON="${{ steps.atmos-plan.outputs.plan_file }}.json" + PLAN_FILE="${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }}" + PLAN_FILE_JSON="${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }}.json" echo $PLAN_FILE echo $PLAN_FILE_JSON + cd ${{ inputs.component-path }} terraform show -json $PLAN_FILE > $PLAN_FILE_JSON cat $PLAN_FILE_JSON | jq . - HAS_CHANGES=$(jq '.resource_changes[] | select(.change.actions[] != "no-op")' "${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }}.json") + HAS_CHANGES=$(jq '.resource_changes[] | select(.change.actions[] != "no-op")' "$PLAN_FILE_JSON") echo "HAS_CHANGES=$HAS_CHANGES" if [[ "$HAS_CHANGES" == "" ]]; then From 7dd84ad0c9a33c229be193c06d36ec44ad1f2aef Mon Sep 17 00:00:00 2001 From: Zinovii Dmytriv Date: Wed, 9 Aug 2023 19:07:12 +0300 Subject: [PATCH 18/61] update --- action.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index 9da1cbee6..8ca6fec9c 100644 --- a/action.yml +++ b/action.yml @@ -161,9 +161,10 @@ runs: cd ${{ inputs.component-path }} terraform show -json $PLAN_FILE > $PLAN_FILE_JSON - cat $PLAN_FILE_JSON | jq . + ls -l ${{ steps.atmos-plan.outputs.plan_file_path }}/ + cat $PLAN_FILE_JSON - HAS_CHANGES=$(jq '.resource_changes[] | select(.change.actions[] != "no-op")' "$PLAN_FILE_JSON") + HAS_CHANGES=$(jq '.resource_changes[] | select(.change.actions[] != "no-op")' $PLAN_FILE_JSON) echo "HAS_CHANGES=$HAS_CHANGES" if [[ "$HAS_CHANGES" == "" ]]; then From 3a67818d7c8543a18513df860085983ab0413372 Mon Sep 17 00:00:00 2001 From: Zinovii Dmytriv Date: Wed, 9 Aug 2023 19:14:01 +0300 Subject: [PATCH 19/61] update --- action.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/action.yml b/action.yml index 8ca6fec9c..43bf36117 100644 --- a/action.yml +++ b/action.yml @@ -150,20 +150,17 @@ runs: id: plan-state shell: bash run: | - set -ex - PLAN_FILE="${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }}" PLAN_FILE_JSON="${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }}.json" - echo $PLAN_FILE - echo $PLAN_FILE_JSON - cd ${{ inputs.component-path }} terraform show -json $PLAN_FILE > $PLAN_FILE_JSON ls -l ${{ steps.atmos-plan.outputs.plan_file_path }}/ cat $PLAN_FILE_JSON + jq . $PLAN_FILE_JSON + HAS_CHANGES=$(jq '.resource_changes[] | select(.change.actions[] != "no-op")' $PLAN_FILE_JSON) echo "HAS_CHANGES=$HAS_CHANGES" From 0cc1fb7962e8738b4c50d6555b534e40da191a6f Mon Sep 17 00:00:00 2001 From: Zinovii Dmytriv Date: Wed, 9 Aug 2023 19:16:56 +0300 Subject: [PATCH 20/61] update --- action.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/action.yml b/action.yml index 43bf36117..a821e256d 100644 --- a/action.yml +++ b/action.yml @@ -156,9 +156,6 @@ runs: cd ${{ inputs.component-path }} terraform show -json $PLAN_FILE > $PLAN_FILE_JSON - ls -l ${{ steps.atmos-plan.outputs.plan_file_path }}/ - cat $PLAN_FILE_JSON - jq . $PLAN_FILE_JSON HAS_CHANGES=$(jq '.resource_changes[] | select(.change.actions[] != "no-op")' $PLAN_FILE_JSON) From 8f5df1d1c523cff36215025bfc971b2196038077 Mon Sep 17 00:00:00 2001 From: Zinovii Dmytriv Date: Wed, 9 Aug 2023 19:20:25 +0300 Subject: [PATCH 21/61] update --- action.yml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/action.yml b/action.yml index a821e256d..b20c150d6 100644 --- a/action.yml +++ b/action.yml @@ -156,14 +156,17 @@ runs: cd ${{ inputs.component-path }} terraform show -json $PLAN_FILE > $PLAN_FILE_JSON + cat $PLAN_FILE_JSON + + jq --version jq . $PLAN_FILE_JSON - HAS_CHANGES=$(jq '.resource_changes[] | select(.change.actions[] != "no-op")' $PLAN_FILE_JSON) - echo "HAS_CHANGES=$HAS_CHANGES" + # HAS_CHANGES=$(jq '.resource_changes[] | select(.change.actions[] != "no-op")' $PLAN_FILE_JSON) + # echo "HAS_CHANGES=$HAS_CHANGES" - if [[ "$HAS_CHANGES" == "" ]]; then - echo "HAS_CHANGES=false" >> $GITHUB_ENV - fi + # if [[ "$HAS_CHANGES" == "" ]]; then + # echo "HAS_CHANGES=false" >> $GITHUB_ENV + # fi - name: Configure State AWS Credentials if: env.HAS_CHANGES == 'true' From b91472516ed20fec31ed6b84f76237a25dbc3198 Mon Sep 17 00:00:00 2001 From: Zinovii Dmytriv Date: Wed, 9 Aug 2023 19:31:44 +0300 Subject: [PATCH 22/61] update --- action.yml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/action.yml b/action.yml index b20c150d6..0c11e25f1 100644 --- a/action.yml +++ b/action.yml @@ -156,10 +156,15 @@ runs: cd ${{ inputs.component-path }} terraform show -json $PLAN_FILE > $PLAN_FILE_JSON - cat $PLAN_FILE_JSON + json_output=$(terraform show -json $PLAN_FILE) + change_summary=$(echo "$json_output" | jq '.resource_changes | map(select(.change.actions | length > 0)) | length') + + if [[ $change_summary -gt 0 ]]; then + echo "There are changes." + else + echo "No changes." + fi - jq --version - jq . $PLAN_FILE_JSON # HAS_CHANGES=$(jq '.resource_changes[] | select(.change.actions[] != "no-op")' $PLAN_FILE_JSON) # echo "HAS_CHANGES=$HAS_CHANGES" From 9f58bc19004130e93302666625212d9b5fea4af5 Mon Sep 17 00:00:00 2001 From: Zinovii Dmytriv Date: Wed, 9 Aug 2023 19:57:47 +0300 Subject: [PATCH 23/61] update --- action.yml | 34 +++++----------------------------- 1 file changed, 5 insertions(+), 29 deletions(-) diff --git a/action.yml b/action.yml index 0c11e25f1..f3f5a9b8e 100644 --- a/action.yml +++ b/action.yml @@ -141,38 +141,14 @@ runs: ATMOS_BASE_PATH=$GITHUB_WORKSPACE atmos terraform plan ${{ inputs.component }} \ --stack ${{ inputs.stack }} \ -out=$PLAN_FILE_PATH/$PLAN_FILE \ - -input=false + -input=false -detailed-exitcode + EXIT_CODE=$? + if [[ "$EXIT_CODE" != "0" ]]; then + echo "HAS_CHANGES=false" >> $GITHUB_ENV + fi echo "plan_file=$PLAN_FILE" >> $GITHUB_OUTPUT echo "plan_file_path=$PLAN_FILE_PATH" >> $GITHUB_OUTPUT - - name: Plan Has Changes - if: ${{ fromJSON(steps.settings.outputs.actions_enabled) }} - id: plan-state - shell: bash - run: | - PLAN_FILE="${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }}" - PLAN_FILE_JSON="${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }}.json" - - cd ${{ inputs.component-path }} - terraform show -json $PLAN_FILE > $PLAN_FILE_JSON - - json_output=$(terraform show -json $PLAN_FILE) - change_summary=$(echo "$json_output" | jq '.resource_changes | map(select(.change.actions | length > 0)) | length') - - if [[ $change_summary -gt 0 ]]; then - echo "There are changes." - else - echo "No changes." - fi - - - # HAS_CHANGES=$(jq '.resource_changes[] | select(.change.actions[] != "no-op")' $PLAN_FILE_JSON) - # echo "HAS_CHANGES=$HAS_CHANGES" - - # if [[ "$HAS_CHANGES" == "" ]]; then - # echo "HAS_CHANGES=false" >> $GITHUB_ENV - # fi - - name: Configure State AWS Credentials if: env.HAS_CHANGES == 'true' uses: aws-actions/configure-aws-credentials@v2.2.0 From 217a6d9f4811d47be1462dad2466ba5394b19ea3 Mon Sep 17 00:00:00 2001 From: Zinovii Dmytriv Date: Wed, 9 Aug 2023 20:01:17 +0300 Subject: [PATCH 24/61] update --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index f3f5a9b8e..c25130a52 100644 --- a/action.yml +++ b/action.yml @@ -144,7 +144,7 @@ runs: -input=false -detailed-exitcode EXIT_CODE=$? if [[ "$EXIT_CODE" != "0" ]]; then - echo "HAS_CHANGES=false" >> $GITHUB_ENV + echo "HAS_CHANGES='false'" >> $GITHUB_ENV fi echo "plan_file=$PLAN_FILE" >> $GITHUB_OUTPUT echo "plan_file_path=$PLAN_FILE_PATH" >> $GITHUB_OUTPUT From 45ad1fc3febe57c3fc3cc4c095af39fec86c45ff Mon Sep 17 00:00:00 2001 From: Zinovii Dmytriv Date: Wed, 9 Aug 2023 20:08:13 +0300 Subject: [PATCH 25/61] update --- action.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/action.yml b/action.yml index c25130a52..d87235cd7 100644 --- a/action.yml +++ b/action.yml @@ -144,13 +144,13 @@ runs: -input=false -detailed-exitcode EXIT_CODE=$? if [[ "$EXIT_CODE" != "0" ]]; then - echo "HAS_CHANGES='false'" >> $GITHUB_ENV + echo "has_changes='true'" >> $GITHUB_OUTPUT fi echo "plan_file=$PLAN_FILE" >> $GITHUB_OUTPUT echo "plan_file_path=$PLAN_FILE_PATH" >> $GITHUB_OUTPUT - name: Configure State AWS Credentials - if: env.HAS_CHANGES == 'true' + if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) }} uses: aws-actions/configure-aws-credentials@v2.2.0 with: aws-region: ${{ inputs.aws-region }} @@ -159,7 +159,7 @@ runs: mask-aws-account-id: "no" - name: Store Plan - if: env.HAS_CHANGES == 'true' + if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) }} uses: cloudposse/github-action-terraform-plan-storage@v1 id: store-plan with: @@ -171,7 +171,7 @@ runs: bucketName: ${{ inputs.terraform-state-bucket }} - name: Store Lockfile - if: env.HAS_CHANGES == 'true' + if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) }} uses: cloudposse/github-action-terraform-plan-storage@v1 with: action: storePlan @@ -182,13 +182,13 @@ runs: bucketName: ${{ inputs.terraform-state-bucket }} - name: Setup Infracost - if: ${{ env.HAS_CHANGES == 'true' && fromJSON(inputs.enable-infracost) }} + if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) && fromJSON(inputs.enable-infracost) }} uses: infracost/actions/setup@v2 with: api-key: ${{ inputs.infracost-api-key }} - name: Generate Infracost diff - if: ${{ env.HAS_CHANGES == 'true' && fromJSON(inputs.enable-infracost) }} + if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) && fromJSON(inputs.enable-infracost) }} shell: bash run: | PLAN_FILE_JSON="${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }}.json" @@ -207,7 +207,7 @@ runs: --project-name ${{ inputs.stack }}-${{ inputs.component }} \ --out-file=/tmp/infracost.json - - if: ${{ env.HAS_CHANGES == 'true' && fromJSON(inputs.enable-infracost) && fromJSON(inputs.debug) }} + - if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) && fromJSON(inputs.enable-infracost) && fromJSON(inputs.debug) }} shell: bash run: | cat ${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }}.json @@ -215,7 +215,7 @@ runs: cat /tmp/infracost.json - name: Set infracost variables - if: env.HAS_CHANGES == 'true' + if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) && fromJSON(inputs.enable-infracost) }} id: infracost-diff shell: bash run: | @@ -231,7 +231,7 @@ runs: echo "infracost_diff_total_monthly_cost=$INFRACOST_DIFF_TOTAL_MONTHLY_COST" >> "$GITHUB_OUTPUT" - name: Post Plan - if: env.HAS_CHANGES == 'true' + if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) && fromJSON(inputs.enable-infracost) }} id: post-plan shell: bash run: | From c0afc5a64fb98ad18b8fbb67f6b0027949412a3a Mon Sep 17 00:00:00 2001 From: Zinovii Dmytriv Date: Wed, 9 Aug 2023 20:10:42 +0300 Subject: [PATCH 26/61] update --- action.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/action.yml b/action.yml index d87235cd7..473ab39df 100644 --- a/action.yml +++ b/action.yml @@ -103,7 +103,6 @@ runs: else echo "actions_enabled=false" >> $GITHUB_OUTPUT fi - echo "HAS_CHANGES=true" >> $GITHUB_ENV # setup-tfcmt requires this PATH update when running on self-hosted (amazon linux) # https://github.com/shmokmt/actions-setup-tfcmt/blob/main/action.yml#L11C1-L12C1 @@ -145,6 +144,8 @@ runs: EXIT_CODE=$? if [[ "$EXIT_CODE" != "0" ]]; then echo "has_changes='true'" >> $GITHUB_OUTPUT + else + echo "has_changes='false'" >> $GITHUB_OUTPUT fi echo "plan_file=$PLAN_FILE" >> $GITHUB_OUTPUT echo "plan_file_path=$PLAN_FILE_PATH" >> $GITHUB_OUTPUT From 2691228265f1c0c93028e0829e5869cae0ca7da0 Mon Sep 17 00:00:00 2001 From: Zinovii Dmytriv Date: Wed, 9 Aug 2023 20:12:38 +0300 Subject: [PATCH 27/61] update --- action.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/action.yml b/action.yml index 473ab39df..b5263664a 100644 --- a/action.yml +++ b/action.yml @@ -142,6 +142,7 @@ runs: -out=$PLAN_FILE_PATH/$PLAN_FILE \ -input=false -detailed-exitcode EXIT_CODE=$? + echo "EXIT_CODE: $EXIT_CODE" if [[ "$EXIT_CODE" != "0" ]]; then echo "has_changes='true'" >> $GITHUB_OUTPUT else From 0a61e63db433e999be548ac45d00636b3111de08 Mon Sep 17 00:00:00 2001 From: Zinovii Dmytriv Date: Wed, 9 Aug 2023 20:15:14 +0300 Subject: [PATCH 28/61] update --- action.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/action.yml b/action.yml index b5263664a..75c22a17d 100644 --- a/action.yml +++ b/action.yml @@ -66,6 +66,9 @@ outputs: plan-file: description: Plan File value: ${{ steps.atmos-plan.outputs.plan_file }} + has-changes: + description: Has Changes + value: ${{ steps.atmos-plan.outputs.has_changes }} runs: using: "composite" From a8241eb6ac09061a18b5e895685b576b23d5d8e6 Mon Sep 17 00:00:00 2001 From: Zinovii Dmytriv Date: Thu, 10 Aug 2023 12:31:51 +0300 Subject: [PATCH 29/61] update --- action.yml | 132 ++++++++++++++++++++++++++--------------------------- 1 file changed, 66 insertions(+), 66 deletions(-) diff --git a/action.yml b/action.yml index 75c22a17d..7022c7dcb 100644 --- a/action.yml +++ b/action.yml @@ -186,76 +186,76 @@ runs: tableName: ${{ inputs.terraform-state-table }} bucketName: ${{ inputs.terraform-state-bucket }} - - name: Setup Infracost - if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) && fromJSON(inputs.enable-infracost) }} - uses: infracost/actions/setup@v2 - with: - api-key: ${{ inputs.infracost-api-key }} + # - name: Setup Infracost + # if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) && fromJSON(inputs.enable-infracost) }} + # uses: infracost/actions/setup@v2 + # with: + # api-key: ${{ inputs.infracost-api-key }} - - name: Generate Infracost diff - if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) && fromJSON(inputs.enable-infracost) }} - shell: bash - run: | - PLAN_FILE_JSON="${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }}.json" + # - name: Generate Infracost diff + # if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) && fromJSON(inputs.enable-infracost) }} + # shell: bash + # run: | + # PLAN_FILE_JSON="${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }}.json" - cd ${{ inputs.component-path }} - terraform show -json $PLAN_FILE > $PLAN_FILE_JSON + # cd ${{ inputs.component-path }} + # terraform show -json $PLAN_FILE > $PLAN_FILE_JSON - infracost diff \ - --path=$PLAN_FILE_JSON \ - --format=diff \ - --project-name ${{ inputs.stack }}-${{ inputs.component }} \ - --out-file=/tmp/infracost.txt - infracost diff \ - --path=$PLAN_FILE_JSON \ - --format=json \ - --project-name ${{ inputs.stack }}-${{ inputs.component }} \ - --out-file=/tmp/infracost.json + # infracost diff \ + # --path=$PLAN_FILE_JSON \ + # --format=diff \ + # --project-name ${{ inputs.stack }}-${{ inputs.component }} \ + # --out-file=/tmp/infracost.txt + # infracost diff \ + # --path=$PLAN_FILE_JSON \ + # --format=json \ + # --project-name ${{ inputs.stack }}-${{ inputs.component }} \ + # --out-file=/tmp/infracost.json - - if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) && fromJSON(inputs.enable-infracost) && fromJSON(inputs.debug) }} - shell: bash - run: | - cat ${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }}.json - cat /tmp/infracost.txt - cat /tmp/infracost.json + # - if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) && fromJSON(inputs.enable-infracost) && fromJSON(inputs.debug) }} + # shell: bash + # run: | + # cat ${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }}.json + # cat /tmp/infracost.txt + # cat /tmp/infracost.json - - name: Set infracost variables - if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) && fromJSON(inputs.enable-infracost) }} - id: infracost-diff - shell: bash - run: | - if [[ "${{ inputs.enable-infracost }}" == "true" ]]; then - INFRACOST_DIFF_TOTAL_MONTHLY_COST=$(cat /tmp/infracost.json | jq --raw-output .diffTotalMonthlyCost) - INFRACOST_DETAILS_DIFF_BREAKDOWN="$(cat /tmp/infracost.txt | base64 --wrap 0)" - else - INFRACOST_DIFF_TOTAL_MONTHLY_COST="0" - INFRACOST_DETAILS_DIFF_BREAKDOWN="" - fi + # - name: Set infracost variables + # if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) && fromJSON(inputs.enable-infracost) }} + # id: infracost-diff + # shell: bash + # run: | + # if [[ "${{ inputs.enable-infracost }}" == "true" ]]; then + # INFRACOST_DIFF_TOTAL_MONTHLY_COST=$(cat /tmp/infracost.json | jq --raw-output .diffTotalMonthlyCost) + # INFRACOST_DETAILS_DIFF_BREAKDOWN="$(cat /tmp/infracost.txt | base64 --wrap 0)" + # else + # INFRACOST_DIFF_TOTAL_MONTHLY_COST="0" + # INFRACOST_DETAILS_DIFF_BREAKDOWN="" + # fi - echo "infracost_details_diff_breakdown=$INFRACOST_DETAILS_DIFF_BREAKDOWN" >> "$GITHUB_OUTPUT" - echo "infracost_diff_total_monthly_cost=$INFRACOST_DIFF_TOTAL_MONTHLY_COST" >> "$GITHUB_OUTPUT" + # echo "infracost_details_diff_breakdown=$INFRACOST_DETAILS_DIFF_BREAKDOWN" >> "$GITHUB_OUTPUT" + # echo "infracost_diff_total_monthly_cost=$INFRACOST_DIFF_TOTAL_MONTHLY_COST" >> "$GITHUB_OUTPUT" - - name: Post Plan - if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) && fromJSON(inputs.enable-infracost) }} - id: post-plan - shell: bash - run: | - if [[ "${{ inputs.debug }}" == "true" ]]; then - LOG_LEVEL="DEBUG" - else - LOG_LEVEL="INFO" - fi - cd ${{ inputs.component-path }} - tfcmt \ - --config "${{ github.action_path }}/config/atmos_github_summary.yaml" \ - -owner "${{ github.repository_owner }}" \ - -repo "${{ github.event.repository.name }}" \ - -var "target:${{ inputs.stack }}-${{ inputs.component }}" \ - -var "component:${{ inputs.component }}" \ - -var "stack:${{ inputs.stack }}" \ - -var "job:${{ github.job }}" \ - -var "infracost_details_diff_breakdown:${{ steps.infracost-diff.outputs.infracost_details_diff_breakdown }}" \ - -var "infracost_total_monthly_cost:${{ steps.infracost-diff.outputs.infracost_diff_total_monthly_cost }}" \ - --output $GITHUB_STEP_SUMMARY \ - --log-level $LOG_LEVEL \ - plan -- terraform show ${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }} + # - name: Post Plan + # if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) && fromJSON(inputs.enable-infracost) }} + # id: post-plan + # shell: bash + # run: | + # if [[ "${{ inputs.debug }}" == "true" ]]; then + # LOG_LEVEL="DEBUG" + # else + # LOG_LEVEL="INFO" + # fi + # cd ${{ inputs.component-path }} + # tfcmt \ + # --config "${{ github.action_path }}/config/atmos_github_summary.yaml" \ + # -owner "${{ github.repository_owner }}" \ + # -repo "${{ github.event.repository.name }}" \ + # -var "target:${{ inputs.stack }}-${{ inputs.component }}" \ + # -var "component:${{ inputs.component }}" \ + # -var "stack:${{ inputs.stack }}" \ + # -var "job:${{ github.job }}" \ + # -var "infracost_details_diff_breakdown:${{ steps.infracost-diff.outputs.infracost_details_diff_breakdown }}" \ + # -var "infracost_total_monthly_cost:${{ steps.infracost-diff.outputs.infracost_diff_total_monthly_cost }}" \ + # --output $GITHUB_STEP_SUMMARY \ + # --log-level $LOG_LEVEL \ + # plan -- terraform show ${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }} From 84edc5d5a063c1986438ef5792495c54ffdf6685 Mon Sep 17 00:00:00 2001 From: Zinovii Dmytriv Date: Thu, 10 Aug 2023 12:38:13 +0300 Subject: [PATCH 30/61] update --- action.yml | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/action.yml b/action.yml index 7022c7dcb..b80f29a9d 100644 --- a/action.yml +++ b/action.yml @@ -154,6 +154,11 @@ runs: echo "plan_file=$PLAN_FILE" >> $GITHUB_OUTPUT echo "plan_file_path=$PLAN_FILE_PATH" >> $GITHUB_OUTPUT + - shell: bash + run: | + echo "has_changes: ${{ steps.atmos-plan.outputs.has_changes }}" + echo "has_changes_json: ${{ fromJSON(steps.atmos-plan.outputs.has_changes) }}" + - name: Configure State AWS Credentials if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) }} uses: aws-actions/configure-aws-credentials@v2.2.0 @@ -175,16 +180,17 @@ runs: tableName: ${{ inputs.terraform-state-table }} bucketName: ${{ inputs.terraform-state-bucket }} - - name: Store Lockfile - if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) }} - uses: cloudposse/github-action-terraform-plan-storage@v1 - with: - action: storePlan - planPath: ${{ inputs.component-path}}/.terraform.lock.hcl - component: ${{ inputs.component }} - stack: "${{ inputs.stack }}-lockfile" - tableName: ${{ inputs.terraform-state-table }} - bucketName: ${{ inputs.terraform-state-bucket }} + # - name: Store Lockfile + # if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) }} + # uses: cloudposse/github-action-terraform-plan-storage@v1 + # with: + # action: storePlan + # planPath: ${{ inputs.component-path}}/.terraform.lock.hcl + # component: ${{ inputs.component }} + # stack: "${{ inputs.stack }}-lockfile" + # tableName: ${{ inputs.terraform-state-table }} + # bucketName: ${{ inputs.terraform-state-bucket }} + # - name: Setup Infracost # if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) && fromJSON(inputs.enable-infracost) }} From b2726f96bd17cddedf07bd07030c51a0f68d423e Mon Sep 17 00:00:00 2001 From: Zinovii Dmytriv Date: Thu, 10 Aug 2023 12:40:46 +0300 Subject: [PATCH 31/61] update --- action.yml | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/action.yml b/action.yml index b80f29a9d..3699604c6 100644 --- a/action.yml +++ b/action.yml @@ -159,26 +159,26 @@ runs: echo "has_changes: ${{ steps.atmos-plan.outputs.has_changes }}" echo "has_changes_json: ${{ fromJSON(steps.atmos-plan.outputs.has_changes) }}" - - name: Configure State AWS Credentials - if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) }} - uses: aws-actions/configure-aws-credentials@v2.2.0 - with: - aws-region: ${{ inputs.aws-region }} - role-to-assume: ${{ inputs.terraform-state-role }} - role-session-name: "atmos-terraform-state-gitops" - mask-aws-account-id: "no" + # - name: Configure State AWS Credentials + # if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) }} + # uses: aws-actions/configure-aws-credentials@v2.2.0 + # with: + # aws-region: ${{ inputs.aws-region }} + # role-to-assume: ${{ inputs.terraform-state-role }} + # role-session-name: "atmos-terraform-state-gitops" + # mask-aws-account-id: "no" - - name: Store Plan - if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) }} - uses: cloudposse/github-action-terraform-plan-storage@v1 - id: store-plan - with: - action: storePlan - planPath: ${{ steps.atmos-plan.outputs.plan_file }} - component: ${{ inputs.component }} - stack: ${{ inputs.stack }} - tableName: ${{ inputs.terraform-state-table }} - bucketName: ${{ inputs.terraform-state-bucket }} + # - name: Store Plan + # if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) }} + # uses: cloudposse/github-action-terraform-plan-storage@v1 + # id: store-plan + # with: + # action: storePlan + # planPath: ${{ steps.atmos-plan.outputs.plan_file }} + # component: ${{ inputs.component }} + # stack: ${{ inputs.stack }} + # tableName: ${{ inputs.terraform-state-table }} + # bucketName: ${{ inputs.terraform-state-bucket }} # - name: Store Lockfile # if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) }} From e4661d4788a3920d60b42634ef398910a980a8f8 Mon Sep 17 00:00:00 2001 From: Zinovii Dmytriv Date: Thu, 10 Aug 2023 13:03:59 +0300 Subject: [PATCH 32/61] update --- action.yml | 59 +++++++++++++++++++++++++++--------------------------- 1 file changed, 29 insertions(+), 30 deletions(-) diff --git a/action.yml b/action.yml index 3699604c6..690aeac60 100644 --- a/action.yml +++ b/action.yml @@ -159,38 +159,37 @@ runs: echo "has_changes: ${{ steps.atmos-plan.outputs.has_changes }}" echo "has_changes_json: ${{ fromJSON(steps.atmos-plan.outputs.has_changes) }}" - # - name: Configure State AWS Credentials - # if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) }} - # uses: aws-actions/configure-aws-credentials@v2.2.0 - # with: - # aws-region: ${{ inputs.aws-region }} - # role-to-assume: ${{ inputs.terraform-state-role }} - # role-session-name: "atmos-terraform-state-gitops" - # mask-aws-account-id: "no" - - # - name: Store Plan - # if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) }} - # uses: cloudposse/github-action-terraform-plan-storage@v1 - # id: store-plan - # with: - # action: storePlan - # planPath: ${{ steps.atmos-plan.outputs.plan_file }} - # component: ${{ inputs.component }} - # stack: ${{ inputs.stack }} - # tableName: ${{ inputs.terraform-state-table }} - # bucketName: ${{ inputs.terraform-state-bucket }} + - name: Configure State AWS Credentials + if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) }} + uses: aws-actions/configure-aws-credentials@v2.2.0 + with: + aws-region: ${{ inputs.aws-region }} + role-to-assume: ${{ inputs.terraform-state-role }} + role-session-name: "atmos-terraform-state-gitops" + mask-aws-account-id: "no" - # - name: Store Lockfile - # if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) }} - # uses: cloudposse/github-action-terraform-plan-storage@v1 - # with: - # action: storePlan - # planPath: ${{ inputs.component-path}}/.terraform.lock.hcl - # component: ${{ inputs.component }} - # stack: "${{ inputs.stack }}-lockfile" - # tableName: ${{ inputs.terraform-state-table }} - # bucketName: ${{ inputs.terraform-state-bucket }} + - name: Store Plan + if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) }} + uses: cloudposse/github-action-terraform-plan-storage@v1 + id: store-plan + with: + action: storePlan + planPath: ${{ steps.atmos-plan.outputs.plan_file }} + component: ${{ inputs.component }} + stack: ${{ inputs.stack }} + tableName: ${{ inputs.terraform-state-table }} + bucketName: ${{ inputs.terraform-state-bucket }} + - name: Store Lockfile + if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) }} + uses: cloudposse/github-action-terraform-plan-storage@v1 + with: + action: storePlan + planPath: ${{ inputs.component-path}}/.terraform.lock.hcl + component: ${{ inputs.component }} + stack: "${{ inputs.stack }}-lockfile" + tableName: ${{ inputs.terraform-state-table }} + bucketName: ${{ inputs.terraform-state-bucket }} # - name: Setup Infracost # if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) && fromJSON(inputs.enable-infracost) }} From 0fbb4ec547b95df583f35685fbece2bdd681c690 Mon Sep 17 00:00:00 2001 From: Zinovii Dmytriv Date: Thu, 10 Aug 2023 13:55:49 +0300 Subject: [PATCH 33/61] update --- action.yml | 137 ++++++++++++++++++++++++++--------------------------- 1 file changed, 66 insertions(+), 71 deletions(-) diff --git a/action.yml b/action.yml index 690aeac60..75c22a17d 100644 --- a/action.yml +++ b/action.yml @@ -154,11 +154,6 @@ runs: echo "plan_file=$PLAN_FILE" >> $GITHUB_OUTPUT echo "plan_file_path=$PLAN_FILE_PATH" >> $GITHUB_OUTPUT - - shell: bash - run: | - echo "has_changes: ${{ steps.atmos-plan.outputs.has_changes }}" - echo "has_changes_json: ${{ fromJSON(steps.atmos-plan.outputs.has_changes) }}" - - name: Configure State AWS Credentials if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) }} uses: aws-actions/configure-aws-credentials@v2.2.0 @@ -191,76 +186,76 @@ runs: tableName: ${{ inputs.terraform-state-table }} bucketName: ${{ inputs.terraform-state-bucket }} - # - name: Setup Infracost - # if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) && fromJSON(inputs.enable-infracost) }} - # uses: infracost/actions/setup@v2 - # with: - # api-key: ${{ inputs.infracost-api-key }} + - name: Setup Infracost + if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) && fromJSON(inputs.enable-infracost) }} + uses: infracost/actions/setup@v2 + with: + api-key: ${{ inputs.infracost-api-key }} - # - name: Generate Infracost diff - # if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) && fromJSON(inputs.enable-infracost) }} - # shell: bash - # run: | - # PLAN_FILE_JSON="${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }}.json" + - name: Generate Infracost diff + if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) && fromJSON(inputs.enable-infracost) }} + shell: bash + run: | + PLAN_FILE_JSON="${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }}.json" - # cd ${{ inputs.component-path }} - # terraform show -json $PLAN_FILE > $PLAN_FILE_JSON + cd ${{ inputs.component-path }} + terraform show -json $PLAN_FILE > $PLAN_FILE_JSON - # infracost diff \ - # --path=$PLAN_FILE_JSON \ - # --format=diff \ - # --project-name ${{ inputs.stack }}-${{ inputs.component }} \ - # --out-file=/tmp/infracost.txt - # infracost diff \ - # --path=$PLAN_FILE_JSON \ - # --format=json \ - # --project-name ${{ inputs.stack }}-${{ inputs.component }} \ - # --out-file=/tmp/infracost.json + infracost diff \ + --path=$PLAN_FILE_JSON \ + --format=diff \ + --project-name ${{ inputs.stack }}-${{ inputs.component }} \ + --out-file=/tmp/infracost.txt + infracost diff \ + --path=$PLAN_FILE_JSON \ + --format=json \ + --project-name ${{ inputs.stack }}-${{ inputs.component }} \ + --out-file=/tmp/infracost.json - # - if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) && fromJSON(inputs.enable-infracost) && fromJSON(inputs.debug) }} - # shell: bash - # run: | - # cat ${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }}.json - # cat /tmp/infracost.txt - # cat /tmp/infracost.json + - if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) && fromJSON(inputs.enable-infracost) && fromJSON(inputs.debug) }} + shell: bash + run: | + cat ${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }}.json + cat /tmp/infracost.txt + cat /tmp/infracost.json - # - name: Set infracost variables - # if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) && fromJSON(inputs.enable-infracost) }} - # id: infracost-diff - # shell: bash - # run: | - # if [[ "${{ inputs.enable-infracost }}" == "true" ]]; then - # INFRACOST_DIFF_TOTAL_MONTHLY_COST=$(cat /tmp/infracost.json | jq --raw-output .diffTotalMonthlyCost) - # INFRACOST_DETAILS_DIFF_BREAKDOWN="$(cat /tmp/infracost.txt | base64 --wrap 0)" - # else - # INFRACOST_DIFF_TOTAL_MONTHLY_COST="0" - # INFRACOST_DETAILS_DIFF_BREAKDOWN="" - # fi + - name: Set infracost variables + if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) && fromJSON(inputs.enable-infracost) }} + id: infracost-diff + shell: bash + run: | + if [[ "${{ inputs.enable-infracost }}" == "true" ]]; then + INFRACOST_DIFF_TOTAL_MONTHLY_COST=$(cat /tmp/infracost.json | jq --raw-output .diffTotalMonthlyCost) + INFRACOST_DETAILS_DIFF_BREAKDOWN="$(cat /tmp/infracost.txt | base64 --wrap 0)" + else + INFRACOST_DIFF_TOTAL_MONTHLY_COST="0" + INFRACOST_DETAILS_DIFF_BREAKDOWN="" + fi - # echo "infracost_details_diff_breakdown=$INFRACOST_DETAILS_DIFF_BREAKDOWN" >> "$GITHUB_OUTPUT" - # echo "infracost_diff_total_monthly_cost=$INFRACOST_DIFF_TOTAL_MONTHLY_COST" >> "$GITHUB_OUTPUT" + echo "infracost_details_diff_breakdown=$INFRACOST_DETAILS_DIFF_BREAKDOWN" >> "$GITHUB_OUTPUT" + echo "infracost_diff_total_monthly_cost=$INFRACOST_DIFF_TOTAL_MONTHLY_COST" >> "$GITHUB_OUTPUT" - # - name: Post Plan - # if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) && fromJSON(inputs.enable-infracost) }} - # id: post-plan - # shell: bash - # run: | - # if [[ "${{ inputs.debug }}" == "true" ]]; then - # LOG_LEVEL="DEBUG" - # else - # LOG_LEVEL="INFO" - # fi - # cd ${{ inputs.component-path }} - # tfcmt \ - # --config "${{ github.action_path }}/config/atmos_github_summary.yaml" \ - # -owner "${{ github.repository_owner }}" \ - # -repo "${{ github.event.repository.name }}" \ - # -var "target:${{ inputs.stack }}-${{ inputs.component }}" \ - # -var "component:${{ inputs.component }}" \ - # -var "stack:${{ inputs.stack }}" \ - # -var "job:${{ github.job }}" \ - # -var "infracost_details_diff_breakdown:${{ steps.infracost-diff.outputs.infracost_details_diff_breakdown }}" \ - # -var "infracost_total_monthly_cost:${{ steps.infracost-diff.outputs.infracost_diff_total_monthly_cost }}" \ - # --output $GITHUB_STEP_SUMMARY \ - # --log-level $LOG_LEVEL \ - # plan -- terraform show ${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }} + - name: Post Plan + if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) && fromJSON(inputs.enable-infracost) }} + id: post-plan + shell: bash + run: | + if [[ "${{ inputs.debug }}" == "true" ]]; then + LOG_LEVEL="DEBUG" + else + LOG_LEVEL="INFO" + fi + cd ${{ inputs.component-path }} + tfcmt \ + --config "${{ github.action_path }}/config/atmos_github_summary.yaml" \ + -owner "${{ github.repository_owner }}" \ + -repo "${{ github.event.repository.name }}" \ + -var "target:${{ inputs.stack }}-${{ inputs.component }}" \ + -var "component:${{ inputs.component }}" \ + -var "stack:${{ inputs.stack }}" \ + -var "job:${{ github.job }}" \ + -var "infracost_details_diff_breakdown:${{ steps.infracost-diff.outputs.infracost_details_diff_breakdown }}" \ + -var "infracost_total_monthly_cost:${{ steps.infracost-diff.outputs.infracost_diff_total_monthly_cost }}" \ + --output $GITHUB_STEP_SUMMARY \ + --log-level $LOG_LEVEL \ + plan -- terraform show ${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }} From 1082e8ca377b982257bd50573add325986b0bcc2 Mon Sep 17 00:00:00 2001 From: Zinovii Dmytriv Date: Thu, 10 Aug 2023 14:19:25 +0300 Subject: [PATCH 34/61] update --- action.yml | 194 ++++++++++++++++++++++++++--------------------------- 1 file changed, 97 insertions(+), 97 deletions(-) diff --git a/action.yml b/action.yml index 75c22a17d..31ed25de7 100644 --- a/action.yml +++ b/action.yml @@ -147,115 +147,115 @@ runs: EXIT_CODE=$? echo "EXIT_CODE: $EXIT_CODE" if [[ "$EXIT_CODE" != "0" ]]; then - echo "has_changes='true'" >> $GITHUB_OUTPUT + echo "has_changes=true" >> $GITHUB_OUTPUT else - echo "has_changes='false'" >> $GITHUB_OUTPUT + echo "has_changes=false" >> $GITHUB_OUTPUT fi echo "plan_file=$PLAN_FILE" >> $GITHUB_OUTPUT echo "plan_file_path=$PLAN_FILE_PATH" >> $GITHUB_OUTPUT - - name: Configure State AWS Credentials - if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) }} - uses: aws-actions/configure-aws-credentials@v2.2.0 - with: - aws-region: ${{ inputs.aws-region }} - role-to-assume: ${{ inputs.terraform-state-role }} - role-session-name: "atmos-terraform-state-gitops" - mask-aws-account-id: "no" + # - name: Configure State AWS Credentials + # if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) }} + # uses: aws-actions/configure-aws-credentials@v2.2.0 + # with: + # aws-region: ${{ inputs.aws-region }} + # role-to-assume: ${{ inputs.terraform-state-role }} + # role-session-name: "atmos-terraform-state-gitops" + # mask-aws-account-id: "no" - - name: Store Plan - if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) }} - uses: cloudposse/github-action-terraform-plan-storage@v1 - id: store-plan - with: - action: storePlan - planPath: ${{ steps.atmos-plan.outputs.plan_file }} - component: ${{ inputs.component }} - stack: ${{ inputs.stack }} - tableName: ${{ inputs.terraform-state-table }} - bucketName: ${{ inputs.terraform-state-bucket }} + # - name: Store Plan + # if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) }} + # uses: cloudposse/github-action-terraform-plan-storage@v1 + # id: store-plan + # with: + # action: storePlan + # planPath: ${{ steps.atmos-plan.outputs.plan_file }} + # component: ${{ inputs.component }} + # stack: ${{ inputs.stack }} + # tableName: ${{ inputs.terraform-state-table }} + # bucketName: ${{ inputs.terraform-state-bucket }} - - name: Store Lockfile - if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) }} - uses: cloudposse/github-action-terraform-plan-storage@v1 - with: - action: storePlan - planPath: ${{ inputs.component-path}}/.terraform.lock.hcl - component: ${{ inputs.component }} - stack: "${{ inputs.stack }}-lockfile" - tableName: ${{ inputs.terraform-state-table }} - bucketName: ${{ inputs.terraform-state-bucket }} + # - name: Store Lockfile + # if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) }} + # uses: cloudposse/github-action-terraform-plan-storage@v1 + # with: + # action: storePlan + # planPath: ${{ inputs.component-path}}/.terraform.lock.hcl + # component: ${{ inputs.component }} + # stack: "${{ inputs.stack }}-lockfile" + # tableName: ${{ inputs.terraform-state-table }} + # bucketName: ${{ inputs.terraform-state-bucket }} - - name: Setup Infracost - if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) && fromJSON(inputs.enable-infracost) }} - uses: infracost/actions/setup@v2 - with: - api-key: ${{ inputs.infracost-api-key }} + # - name: Setup Infracost + # if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) && fromJSON(inputs.enable-infracost) }} + # uses: infracost/actions/setup@v2 + # with: + # api-key: ${{ inputs.infracost-api-key }} - - name: Generate Infracost diff - if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) && fromJSON(inputs.enable-infracost) }} - shell: bash - run: | - PLAN_FILE_JSON="${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }}.json" + # - name: Generate Infracost diff + # if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) && fromJSON(inputs.enable-infracost) }} + # shell: bash + # run: | + # PLAN_FILE_JSON="${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }}.json" - cd ${{ inputs.component-path }} - terraform show -json $PLAN_FILE > $PLAN_FILE_JSON + # cd ${{ inputs.component-path }} + # terraform show -json $PLAN_FILE > $PLAN_FILE_JSON - infracost diff \ - --path=$PLAN_FILE_JSON \ - --format=diff \ - --project-name ${{ inputs.stack }}-${{ inputs.component }} \ - --out-file=/tmp/infracost.txt - infracost diff \ - --path=$PLAN_FILE_JSON \ - --format=json \ - --project-name ${{ inputs.stack }}-${{ inputs.component }} \ - --out-file=/tmp/infracost.json + # infracost diff \ + # --path=$PLAN_FILE_JSON \ + # --format=diff \ + # --project-name ${{ inputs.stack }}-${{ inputs.component }} \ + # --out-file=/tmp/infracost.txt + # infracost diff \ + # --path=$PLAN_FILE_JSON \ + # --format=json \ + # --project-name ${{ inputs.stack }}-${{ inputs.component }} \ + # --out-file=/tmp/infracost.json - - if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) && fromJSON(inputs.enable-infracost) && fromJSON(inputs.debug) }} - shell: bash - run: | - cat ${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }}.json - cat /tmp/infracost.txt - cat /tmp/infracost.json + # - if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) && fromJSON(inputs.enable-infracost) && fromJSON(inputs.debug) }} + # shell: bash + # run: | + # cat ${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }}.json + # cat /tmp/infracost.txt + # cat /tmp/infracost.json - - name: Set infracost variables - if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) && fromJSON(inputs.enable-infracost) }} - id: infracost-diff - shell: bash - run: | - if [[ "${{ inputs.enable-infracost }}" == "true" ]]; then - INFRACOST_DIFF_TOTAL_MONTHLY_COST=$(cat /tmp/infracost.json | jq --raw-output .diffTotalMonthlyCost) - INFRACOST_DETAILS_DIFF_BREAKDOWN="$(cat /tmp/infracost.txt | base64 --wrap 0)" - else - INFRACOST_DIFF_TOTAL_MONTHLY_COST="0" - INFRACOST_DETAILS_DIFF_BREAKDOWN="" - fi + # - name: Set infracost variables + # if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) && fromJSON(inputs.enable-infracost) }} + # id: infracost-diff + # shell: bash + # run: | + # if [[ "${{ inputs.enable-infracost }}" == "true" ]]; then + # INFRACOST_DIFF_TOTAL_MONTHLY_COST=$(cat /tmp/infracost.json | jq --raw-output .diffTotalMonthlyCost) + # INFRACOST_DETAILS_DIFF_BREAKDOWN="$(cat /tmp/infracost.txt | base64 --wrap 0)" + # else + # INFRACOST_DIFF_TOTAL_MONTHLY_COST="0" + # INFRACOST_DETAILS_DIFF_BREAKDOWN="" + # fi - echo "infracost_details_diff_breakdown=$INFRACOST_DETAILS_DIFF_BREAKDOWN" >> "$GITHUB_OUTPUT" - echo "infracost_diff_total_monthly_cost=$INFRACOST_DIFF_TOTAL_MONTHLY_COST" >> "$GITHUB_OUTPUT" + # echo "infracost_details_diff_breakdown=$INFRACOST_DETAILS_DIFF_BREAKDOWN" >> "$GITHUB_OUTPUT" + # echo "infracost_diff_total_monthly_cost=$INFRACOST_DIFF_TOTAL_MONTHLY_COST" >> "$GITHUB_OUTPUT" - - name: Post Plan - if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) && fromJSON(inputs.enable-infracost) }} - id: post-plan - shell: bash - run: | - if [[ "${{ inputs.debug }}" == "true" ]]; then - LOG_LEVEL="DEBUG" - else - LOG_LEVEL="INFO" - fi - cd ${{ inputs.component-path }} - tfcmt \ - --config "${{ github.action_path }}/config/atmos_github_summary.yaml" \ - -owner "${{ github.repository_owner }}" \ - -repo "${{ github.event.repository.name }}" \ - -var "target:${{ inputs.stack }}-${{ inputs.component }}" \ - -var "component:${{ inputs.component }}" \ - -var "stack:${{ inputs.stack }}" \ - -var "job:${{ github.job }}" \ - -var "infracost_details_diff_breakdown:${{ steps.infracost-diff.outputs.infracost_details_diff_breakdown }}" \ - -var "infracost_total_monthly_cost:${{ steps.infracost-diff.outputs.infracost_diff_total_monthly_cost }}" \ - --output $GITHUB_STEP_SUMMARY \ - --log-level $LOG_LEVEL \ - plan -- terraform show ${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }} + # - name: Post Plan + # if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) && fromJSON(inputs.enable-infracost) }} + # id: post-plan + # shell: bash + # run: | + # if [[ "${{ inputs.debug }}" == "true" ]]; then + # LOG_LEVEL="DEBUG" + # else + # LOG_LEVEL="INFO" + # fi + # cd ${{ inputs.component-path }} + # tfcmt \ + # --config "${{ github.action_path }}/config/atmos_github_summary.yaml" \ + # -owner "${{ github.repository_owner }}" \ + # -repo "${{ github.event.repository.name }}" \ + # -var "target:${{ inputs.stack }}-${{ inputs.component }}" \ + # -var "component:${{ inputs.component }}" \ + # -var "stack:${{ inputs.stack }}" \ + # -var "job:${{ github.job }}" \ + # -var "infracost_details_diff_breakdown:${{ steps.infracost-diff.outputs.infracost_details_diff_breakdown }}" \ + # -var "infracost_total_monthly_cost:${{ steps.infracost-diff.outputs.infracost_diff_total_monthly_cost }}" \ + # --output $GITHUB_STEP_SUMMARY \ + # --log-level $LOG_LEVEL \ + # plan -- terraform show ${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }} From 6d10f5efc3a0c782ce99efb84a54fc7d7469305a Mon Sep 17 00:00:00 2001 From: Zinovii Dmytriv Date: Thu, 10 Aug 2023 14:22:39 +0300 Subject: [PATCH 35/61] update --- action.yml | 190 ++++++++++++++++++++++++++--------------------------- 1 file changed, 95 insertions(+), 95 deletions(-) diff --git a/action.yml b/action.yml index 31ed25de7..39161651d 100644 --- a/action.yml +++ b/action.yml @@ -154,108 +154,108 @@ runs: echo "plan_file=$PLAN_FILE" >> $GITHUB_OUTPUT echo "plan_file_path=$PLAN_FILE_PATH" >> $GITHUB_OUTPUT - # - name: Configure State AWS Credentials - # if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) }} - # uses: aws-actions/configure-aws-credentials@v2.2.0 - # with: - # aws-region: ${{ inputs.aws-region }} - # role-to-assume: ${{ inputs.terraform-state-role }} - # role-session-name: "atmos-terraform-state-gitops" - # mask-aws-account-id: "no" + - name: Configure State AWS Credentials + if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) }} + uses: aws-actions/configure-aws-credentials@v2.2.0 + with: + aws-region: ${{ inputs.aws-region }} + role-to-assume: ${{ inputs.terraform-state-role }} + role-session-name: "atmos-terraform-state-gitops" + mask-aws-account-id: "no" - # - name: Store Plan - # if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) }} - # uses: cloudposse/github-action-terraform-plan-storage@v1 - # id: store-plan - # with: - # action: storePlan - # planPath: ${{ steps.atmos-plan.outputs.plan_file }} - # component: ${{ inputs.component }} - # stack: ${{ inputs.stack }} - # tableName: ${{ inputs.terraform-state-table }} - # bucketName: ${{ inputs.terraform-state-bucket }} + - name: Store Plan + if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) }} + uses: cloudposse/github-action-terraform-plan-storage@v1 + id: store-plan + with: + action: storePlan + planPath: ${{ steps.atmos-plan.outputs.plan_file }} + component: ${{ inputs.component }} + stack: ${{ inputs.stack }} + tableName: ${{ inputs.terraform-state-table }} + bucketName: ${{ inputs.terraform-state-bucket }} - # - name: Store Lockfile - # if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) }} - # uses: cloudposse/github-action-terraform-plan-storage@v1 - # with: - # action: storePlan - # planPath: ${{ inputs.component-path}}/.terraform.lock.hcl - # component: ${{ inputs.component }} - # stack: "${{ inputs.stack }}-lockfile" - # tableName: ${{ inputs.terraform-state-table }} - # bucketName: ${{ inputs.terraform-state-bucket }} + - name: Store Lockfile + if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) }} + uses: cloudposse/github-action-terraform-plan-storage@v1 + with: + action: storePlan + planPath: ${{ inputs.component-path}}/.terraform.lock.hcl + component: ${{ inputs.component }} + stack: "${{ inputs.stack }}-lockfile" + tableName: ${{ inputs.terraform-state-table }} + bucketName: ${{ inputs.terraform-state-bucket }} - # - name: Setup Infracost - # if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) && fromJSON(inputs.enable-infracost) }} - # uses: infracost/actions/setup@v2 - # with: - # api-key: ${{ inputs.infracost-api-key }} + - name: Setup Infracost + if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) && fromJSON(inputs.enable-infracost) }} + uses: infracost/actions/setup@v2 + with: + api-key: ${{ inputs.infracost-api-key }} - # - name: Generate Infracost diff - # if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) && fromJSON(inputs.enable-infracost) }} - # shell: bash - # run: | - # PLAN_FILE_JSON="${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }}.json" + - name: Generate Infracost diff + if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) && fromJSON(inputs.enable-infracost) }} + shell: bash + run: | + PLAN_FILE_JSON="${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }}.json" - # cd ${{ inputs.component-path }} - # terraform show -json $PLAN_FILE > $PLAN_FILE_JSON + cd ${{ inputs.component-path }} + terraform show -json $PLAN_FILE > $PLAN_FILE_JSON - # infracost diff \ - # --path=$PLAN_FILE_JSON \ - # --format=diff \ - # --project-name ${{ inputs.stack }}-${{ inputs.component }} \ - # --out-file=/tmp/infracost.txt - # infracost diff \ - # --path=$PLAN_FILE_JSON \ - # --format=json \ - # --project-name ${{ inputs.stack }}-${{ inputs.component }} \ - # --out-file=/tmp/infracost.json + infracost diff \ + --path=$PLAN_FILE_JSON \ + --format=diff \ + --project-name ${{ inputs.stack }}-${{ inputs.component }} \ + --out-file=/tmp/infracost.txt + infracost diff \ + --path=$PLAN_FILE_JSON \ + --format=json \ + --project-name ${{ inputs.stack }}-${{ inputs.component }} \ + --out-file=/tmp/infracost.json - # - if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) && fromJSON(inputs.enable-infracost) && fromJSON(inputs.debug) }} - # shell: bash - # run: | - # cat ${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }}.json - # cat /tmp/infracost.txt - # cat /tmp/infracost.json + - if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) && fromJSON(inputs.enable-infracost) && fromJSON(inputs.debug) }} + shell: bash + run: | + cat ${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }}.json + cat /tmp/infracost.txt + cat /tmp/infracost.json - # - name: Set infracost variables - # if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) && fromJSON(inputs.enable-infracost) }} - # id: infracost-diff - # shell: bash - # run: | - # if [[ "${{ inputs.enable-infracost }}" == "true" ]]; then - # INFRACOST_DIFF_TOTAL_MONTHLY_COST=$(cat /tmp/infracost.json | jq --raw-output .diffTotalMonthlyCost) - # INFRACOST_DETAILS_DIFF_BREAKDOWN="$(cat /tmp/infracost.txt | base64 --wrap 0)" - # else - # INFRACOST_DIFF_TOTAL_MONTHLY_COST="0" - # INFRACOST_DETAILS_DIFF_BREAKDOWN="" - # fi + - name: Set infracost variables + if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) && fromJSON(inputs.enable-infracost) }} + id: infracost-diff + shell: bash + run: | + if [[ "${{ inputs.enable-infracost }}" == "true" ]]; then + INFRACOST_DIFF_TOTAL_MONTHLY_COST=$(cat /tmp/infracost.json | jq --raw-output .diffTotalMonthlyCost) + INFRACOST_DETAILS_DIFF_BREAKDOWN="$(cat /tmp/infracost.txt | base64 --wrap 0)" + else + INFRACOST_DIFF_TOTAL_MONTHLY_COST="0" + INFRACOST_DETAILS_DIFF_BREAKDOWN="" + fi - # echo "infracost_details_diff_breakdown=$INFRACOST_DETAILS_DIFF_BREAKDOWN" >> "$GITHUB_OUTPUT" - # echo "infracost_diff_total_monthly_cost=$INFRACOST_DIFF_TOTAL_MONTHLY_COST" >> "$GITHUB_OUTPUT" + echo "infracost_details_diff_breakdown=$INFRACOST_DETAILS_DIFF_BREAKDOWN" >> "$GITHUB_OUTPUT" + echo "infracost_diff_total_monthly_cost=$INFRACOST_DIFF_TOTAL_MONTHLY_COST" >> "$GITHUB_OUTPUT" - # - name: Post Plan - # if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) && fromJSON(inputs.enable-infracost) }} - # id: post-plan - # shell: bash - # run: | - # if [[ "${{ inputs.debug }}" == "true" ]]; then - # LOG_LEVEL="DEBUG" - # else - # LOG_LEVEL="INFO" - # fi - # cd ${{ inputs.component-path }} - # tfcmt \ - # --config "${{ github.action_path }}/config/atmos_github_summary.yaml" \ - # -owner "${{ github.repository_owner }}" \ - # -repo "${{ github.event.repository.name }}" \ - # -var "target:${{ inputs.stack }}-${{ inputs.component }}" \ - # -var "component:${{ inputs.component }}" \ - # -var "stack:${{ inputs.stack }}" \ - # -var "job:${{ github.job }}" \ - # -var "infracost_details_diff_breakdown:${{ steps.infracost-diff.outputs.infracost_details_diff_breakdown }}" \ - # -var "infracost_total_monthly_cost:${{ steps.infracost-diff.outputs.infracost_diff_total_monthly_cost }}" \ - # --output $GITHUB_STEP_SUMMARY \ - # --log-level $LOG_LEVEL \ - # plan -- terraform show ${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }} + - name: Post Plan + if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) && fromJSON(inputs.enable-infracost) }} + id: post-plan + shell: bash + run: | + if [[ "${{ inputs.debug }}" == "true" ]]; then + LOG_LEVEL="DEBUG" + else + LOG_LEVEL="INFO" + fi + cd ${{ inputs.component-path }} + tfcmt \ + --config "${{ github.action_path }}/config/atmos_github_summary.yaml" \ + -owner "${{ github.repository_owner }}" \ + -repo "${{ github.event.repository.name }}" \ + -var "target:${{ inputs.stack }}-${{ inputs.component }}" \ + -var "component:${{ inputs.component }}" \ + -var "stack:${{ inputs.stack }}" \ + -var "job:${{ github.job }}" \ + -var "infracost_details_diff_breakdown:${{ steps.infracost-diff.outputs.infracost_details_diff_breakdown }}" \ + -var "infracost_total_monthly_cost:${{ steps.infracost-diff.outputs.infracost_diff_total_monthly_cost }}" \ + --output $GITHUB_STEP_SUMMARY \ + --log-level $LOG_LEVEL \ + plan -- terraform show ${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }} From bae76f256d89425718c8ec075b90ffcb3a79abb1 Mon Sep 17 00:00:00 2001 From: Zinovii Dmytriv Date: Thu, 10 Aug 2023 15:22:33 +0300 Subject: [PATCH 36/61] update --- action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index 39161651d..ed92eeb5c 100644 --- a/action.yml +++ b/action.yml @@ -87,7 +87,7 @@ runs: with: atmos-version: ${{ inputs.atmos-version }} token: ${{ inputs.token }} - install-wrapper: false + install-wrapper: true - name: Filter Atmos Settings Value uses: cloudposse/github-action-atmos-get-setting@v0 @@ -97,7 +97,7 @@ runs: stack: ${{ inputs.stack }} settings-path: github.actions_enabled - - name: Check if Action is Enable + - name: Check if Action is Enabled id: settings shell: bash run: | From ebfc00d26d44017834f864126cd902dab03dee2b Mon Sep 17 00:00:00 2001 From: Zinovii Dmytriv Date: Thu, 10 Aug 2023 15:30:25 +0300 Subject: [PATCH 37/61] update --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index ed92eeb5c..51100592f 100644 --- a/action.yml +++ b/action.yml @@ -87,7 +87,7 @@ runs: with: atmos-version: ${{ inputs.atmos-version }} token: ${{ inputs.token }} - install-wrapper: true + install-wrapper: false - name: Filter Atmos Settings Value uses: cloudposse/github-action-atmos-get-setting@v0 From f891bdf5bf0cce34f631456185964f34dc8b61d3 Mon Sep 17 00:00:00 2001 From: Zinovii Dmytriv Date: Thu, 10 Aug 2023 16:52:38 +0300 Subject: [PATCH 38/61] update --- action.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/action.yml b/action.yml index 51100592f..87e9bc00f 100644 --- a/action.yml +++ b/action.yml @@ -144,6 +144,13 @@ runs: --stack ${{ inputs.stack }} \ -out=$PLAN_FILE_PATH/$PLAN_FILE \ -input=false -detailed-exitcode + + PLAN_FILE_JSON="${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }}.json" + terraform show -json "${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }}" > $PLAN_FILE_JSON + + cat $PLAN_FILE_JSON + jq . $PLAN_FILE_JSON + EXIT_CODE=$? echo "EXIT_CODE: $EXIT_CODE" if [[ "$EXIT_CODE" != "0" ]]; then From e2fbe5ea15222160a82a489681b76563a7b39747 Mon Sep 17 00:00:00 2001 From: Zinovii Dmytriv Date: Thu, 10 Aug 2023 16:55:02 +0300 Subject: [PATCH 39/61] update --- action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index 87e9bc00f..3abe72424 100644 --- a/action.yml +++ b/action.yml @@ -145,8 +145,8 @@ runs: -out=$PLAN_FILE_PATH/$PLAN_FILE \ -input=false -detailed-exitcode - PLAN_FILE_JSON="${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }}.json" - terraform show -json "${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }}" > $PLAN_FILE_JSON + PLAN_FILE_JSON="$PLAN_FILE_PATH/$PLAN_FILE.json" + terraform show -json "$PLAN_FILE_PATH/$PLAN_FILE" > $PLAN_FILE_JSON cat $PLAN_FILE_JSON jq . $PLAN_FILE_JSON From 0db09469b3572e8f56b0584930ad2bedf09fd06f Mon Sep 17 00:00:00 2001 From: Zinovii Dmytriv Date: Thu, 10 Aug 2023 16:58:24 +0300 Subject: [PATCH 40/61] update --- action.yml | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/action.yml b/action.yml index 3abe72424..e9817d2d3 100644 --- a/action.yml +++ b/action.yml @@ -144,13 +144,6 @@ runs: --stack ${{ inputs.stack }} \ -out=$PLAN_FILE_PATH/$PLAN_FILE \ -input=false -detailed-exitcode - - PLAN_FILE_JSON="$PLAN_FILE_PATH/$PLAN_FILE.json" - terraform show -json "$PLAN_FILE_PATH/$PLAN_FILE" > $PLAN_FILE_JSON - - cat $PLAN_FILE_JSON - jq . $PLAN_FILE_JSON - EXIT_CODE=$? echo "EXIT_CODE: $EXIT_CODE" if [[ "$EXIT_CODE" != "0" ]]; then @@ -161,6 +154,17 @@ runs: echo "plan_file=$PLAN_FILE" >> $GITHUB_OUTPUT echo "plan_file_path=$PLAN_FILE_PATH" >> $GITHUB_OUTPUT + - name: json + shell: bash + run: | + PLAN_FILE_JSON="${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }}.json" + + cd ${{ inputs.component-path }} + terraform show -json "$PLAN_FILE_PATH/$PLAN_FILE" > $PLAN_FILE_JSON + + cat $PLAN_FILE_JSON + jq . $PLAN_FILE_JSON + - name: Configure State AWS Credentials if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) }} uses: aws-actions/configure-aws-credentials@v2.2.0 From 6f8650c50a1f6cef33f430695b8fe87abfacd88c Mon Sep 17 00:00:00 2001 From: Zinovii Dmytriv Date: Thu, 10 Aug 2023 17:01:13 +0300 Subject: [PATCH 41/61] update --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index e9817d2d3..2cd74fd22 100644 --- a/action.yml +++ b/action.yml @@ -160,7 +160,7 @@ runs: PLAN_FILE_JSON="${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }}.json" cd ${{ inputs.component-path }} - terraform show -json "$PLAN_FILE_PATH/$PLAN_FILE" > $PLAN_FILE_JSON + terraform show -json "${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }}" > $PLAN_FILE_JSON cat $PLAN_FILE_JSON jq . $PLAN_FILE_JSON From 4e0af4f5874776bf74dd2397fb6ac4a418eb47d9 Mon Sep 17 00:00:00 2001 From: Zinovii Dmytriv Date: Thu, 10 Aug 2023 17:06:10 +0300 Subject: [PATCH 42/61] update --- action.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/action.yml b/action.yml index 2cd74fd22..443145a57 100644 --- a/action.yml +++ b/action.yml @@ -162,7 +162,12 @@ runs: cd ${{ inputs.component-path }} terraform show -json "${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }}" > $PLAN_FILE_JSON + sleep 3 + cat $PLAN_FILE_JSON + + sleep 3 + jq . $PLAN_FILE_JSON - name: Configure State AWS Credentials From 5592acac0e25b9fb26bb1cedc61f22e806415591 Mon Sep 17 00:00:00 2001 From: Zinovii Dmytriv Date: Thu, 10 Aug 2023 17:12:46 +0300 Subject: [PATCH 43/61] update --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 443145a57..419f5918f 100644 --- a/action.yml +++ b/action.yml @@ -168,7 +168,7 @@ runs: sleep 3 - jq . $PLAN_FILE_JSON + jq -e . $PLAN_FILE_JSON - name: Configure State AWS Credentials if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) }} From e7810d781c8ff50d6da2d0cc78efc3b375535679 Mon Sep 17 00:00:00 2001 From: Zinovii Dmytriv Date: Thu, 10 Aug 2023 17:21:14 +0300 Subject: [PATCH 44/61] update --- action.yml | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/action.yml b/action.yml index 419f5918f..cd2619cb4 100644 --- a/action.yml +++ b/action.yml @@ -140,36 +140,22 @@ runs: fi PLAN_FILE_PATH=$(pwd) - ATMOS_BASE_PATH=$GITHUB_WORKSPACE atmos terraform plan ${{ inputs.component }} \ + TERRAFORM_OUTPUT=$(ATMOS_BASE_PATH=$GITHUB_WORKSPACE atmos terraform plan ${{ inputs.component }} \ --stack ${{ inputs.stack }} \ -out=$PLAN_FILE_PATH/$PLAN_FILE \ - -input=false -detailed-exitcode - EXIT_CODE=$? - echo "EXIT_CODE: $EXIT_CODE" - if [[ "$EXIT_CODE" != "0" ]]; then + -input=false -no-color) + + echo "$TERRAFORM_OUTPUT" + + if echo "$TERRAFORM_OUTPUT" | grep -q '^No changes. Your infrastructure matches the configuration.'; then echo "has_changes=true" >> $GITHUB_OUTPUT else echo "has_changes=false" >> $GITHUB_OUTPUT fi + echo "plan_file=$PLAN_FILE" >> $GITHUB_OUTPUT echo "plan_file_path=$PLAN_FILE_PATH" >> $GITHUB_OUTPUT - - name: json - shell: bash - run: | - PLAN_FILE_JSON="${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }}.json" - - cd ${{ inputs.component-path }} - terraform show -json "${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }}" > $PLAN_FILE_JSON - - sleep 3 - - cat $PLAN_FILE_JSON - - sleep 3 - - jq -e . $PLAN_FILE_JSON - - name: Configure State AWS Credentials if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) }} uses: aws-actions/configure-aws-credentials@v2.2.0 From ea77bf451b7618fde54df7066ec4ef3116e7de51 Mon Sep 17 00:00:00 2001 From: Zinovii Dmytriv Date: Thu, 10 Aug 2023 17:22:16 +0300 Subject: [PATCH 45/61] update --- action.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/action.yml b/action.yml index cd2619cb4..f4f680ea3 100644 --- a/action.yml +++ b/action.yml @@ -198,6 +198,7 @@ runs: if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) && fromJSON(inputs.enable-infracost) }} shell: bash run: | + PLAN_FILE="${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }}" PLAN_FILE_JSON="${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }}.json" cd ${{ inputs.component-path }} From bb66c427663a964ad70356302d7f2f259265bbfa Mon Sep 17 00:00:00 2001 From: Zinovii Dmytriv Date: Thu, 10 Aug 2023 17:24:13 +0300 Subject: [PATCH 46/61] update --- action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index f4f680ea3..6381d7e70 100644 --- a/action.yml +++ b/action.yml @@ -148,9 +148,9 @@ runs: echo "$TERRAFORM_OUTPUT" if echo "$TERRAFORM_OUTPUT" | grep -q '^No changes. Your infrastructure matches the configuration.'; then - echo "has_changes=true" >> $GITHUB_OUTPUT - else echo "has_changes=false" >> $GITHUB_OUTPUT + else + echo "has_changes=true" >> $GITHUB_OUTPUT fi echo "plan_file=$PLAN_FILE" >> $GITHUB_OUTPUT From e8889f35b6b3d6c2c74a8d738ff77955f6b3f03d Mon Sep 17 00:00:00 2001 From: Zinovii Dmytriv Date: Thu, 10 Aug 2023 17:41:13 +0300 Subject: [PATCH 47/61] update --- action.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 6381d7e70..41cc07e61 100644 --- a/action.yml +++ b/action.yml @@ -143,7 +143,9 @@ runs: TERRAFORM_OUTPUT=$(ATMOS_BASE_PATH=$GITHUB_WORKSPACE atmos terraform plan ${{ inputs.component }} \ --stack ${{ inputs.stack }} \ -out=$PLAN_FILE_PATH/$PLAN_FILE \ - -input=false -no-color) + -lock=false \ + -input=false \ + -no-color) echo "$TERRAFORM_OUTPUT" From 98a9e7f59637299ac1303a9841b61abe0f25ece1 Mon Sep 17 00:00:00 2001 From: Zinovii Dmytriv Date: Thu, 10 Aug 2023 18:32:30 +0300 Subject: [PATCH 48/61] update --- action.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/action.yml b/action.yml index 41cc07e61..0335fe314 100644 --- a/action.yml +++ b/action.yml @@ -158,6 +158,13 @@ runs: echo "plan_file=$PLAN_FILE" >> $GITHUB_OUTPUT echo "plan_file_path=$PLAN_FILE_PATH" >> $GITHUB_OUTPUT + - name: Has Changes + id: has-changes + shell: bash + run: | + echo ${{ steps.atmos-plan.outputs.has_changes }} + echo ${{ fromJSON(steps.atmos-plan.outputs.has_changes) }} + - name: Configure State AWS Credentials if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) }} uses: aws-actions/configure-aws-credentials@v2.2.0 From abbc8fa537e39fea68cf3333c0358a44a5527554 Mon Sep 17 00:00:00 2001 From: Zinovii Dmytriv Date: Thu, 10 Aug 2023 18:35:25 +0300 Subject: [PATCH 49/61] update --- action.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/action.yml b/action.yml index 0335fe314..31af252c4 100644 --- a/action.yml +++ b/action.yml @@ -164,6 +164,8 @@ runs: run: | echo ${{ steps.atmos-plan.outputs.has_changes }} echo ${{ fromJSON(steps.atmos-plan.outputs.has_changes) }} + echo ${{ "fromJSON(steps.atmos-plan.outputs.has_changes)" == "false" }} + echo ${{ fromJSON(steps.atmos-plan.outputs.has_changes) == false }} - name: Configure State AWS Credentials if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) }} From 11f7328172fc617ebdd8d34747f8713cfec4c49d Mon Sep 17 00:00:00 2001 From: Zinovii Dmytriv Date: Thu, 10 Aug 2023 18:36:21 +0300 Subject: [PATCH 50/61] update --- action.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/action.yml b/action.yml index 31af252c4..17edd5a84 100644 --- a/action.yml +++ b/action.yml @@ -155,6 +155,9 @@ runs: echo "has_changes=true" >> $GITHUB_OUTPUT fi + echo "all outputs: " + echo $GITHUB_OUTPUT + echo "plan_file=$PLAN_FILE" >> $GITHUB_OUTPUT echo "plan_file_path=$PLAN_FILE_PATH" >> $GITHUB_OUTPUT From 7962317c737b73fd1350d9c3e00e3913218ac693 Mon Sep 17 00:00:00 2001 From: Zinovii Dmytriv Date: Thu, 10 Aug 2023 18:37:20 +0300 Subject: [PATCH 51/61] update --- action.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/action.yml b/action.yml index 17edd5a84..1967921ca 100644 --- a/action.yml +++ b/action.yml @@ -167,7 +167,6 @@ runs: run: | echo ${{ steps.atmos-plan.outputs.has_changes }} echo ${{ fromJSON(steps.atmos-plan.outputs.has_changes) }} - echo ${{ "fromJSON(steps.atmos-plan.outputs.has_changes)" == "false" }} echo ${{ fromJSON(steps.atmos-plan.outputs.has_changes) == false }} - name: Configure State AWS Credentials From 6df5e0e22e6cc29f090f7cfd8f2b53e3005bc5ad Mon Sep 17 00:00:00 2001 From: Zinovii Dmytriv Date: Thu, 10 Aug 2023 18:43:40 +0300 Subject: [PATCH 52/61] update --- action.yml | 181 ++++++++++++++++++++++++++--------------------------- 1 file changed, 90 insertions(+), 91 deletions(-) diff --git a/action.yml b/action.yml index 1967921ca..3372ee1a0 100644 --- a/action.yml +++ b/action.yml @@ -151,13 +151,12 @@ runs: if echo "$TERRAFORM_OUTPUT" | grep -q '^No changes. Your infrastructure matches the configuration.'; then echo "has_changes=false" >> $GITHUB_OUTPUT + echo "No changes" else echo "has_changes=true" >> $GITHUB_OUTPUT + echo "Found changes" fi - echo "all outputs: " - echo $GITHUB_OUTPUT - echo "plan_file=$PLAN_FILE" >> $GITHUB_OUTPUT echo "plan_file_path=$PLAN_FILE_PATH" >> $GITHUB_OUTPUT @@ -178,100 +177,100 @@ runs: role-session-name: "atmos-terraform-state-gitops" mask-aws-account-id: "no" - - name: Store Plan - if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) }} - uses: cloudposse/github-action-terraform-plan-storage@v1 - id: store-plan - with: - action: storePlan - planPath: ${{ steps.atmos-plan.outputs.plan_file }} - component: ${{ inputs.component }} - stack: ${{ inputs.stack }} - tableName: ${{ inputs.terraform-state-table }} - bucketName: ${{ inputs.terraform-state-bucket }} + # - name: Store Plan + # if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) }} + # uses: cloudposse/github-action-terraform-plan-storage@v1 + # id: store-plan + # with: + # action: storePlan + # planPath: ${{ steps.atmos-plan.outputs.plan_file }} + # component: ${{ inputs.component }} + # stack: ${{ inputs.stack }} + # tableName: ${{ inputs.terraform-state-table }} + # bucketName: ${{ inputs.terraform-state-bucket }} - - name: Store Lockfile - if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) }} - uses: cloudposse/github-action-terraform-plan-storage@v1 - with: - action: storePlan - planPath: ${{ inputs.component-path}}/.terraform.lock.hcl - component: ${{ inputs.component }} - stack: "${{ inputs.stack }}-lockfile" - tableName: ${{ inputs.terraform-state-table }} - bucketName: ${{ inputs.terraform-state-bucket }} + # - name: Store Lockfile + # if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) }} + # uses: cloudposse/github-action-terraform-plan-storage@v1 + # with: + # action: storePlan + # planPath: ${{ inputs.component-path}}/.terraform.lock.hcl + # component: ${{ inputs.component }} + # stack: "${{ inputs.stack }}-lockfile" + # tableName: ${{ inputs.terraform-state-table }} + # bucketName: ${{ inputs.terraform-state-bucket }} - - name: Setup Infracost - if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) && fromJSON(inputs.enable-infracost) }} - uses: infracost/actions/setup@v2 - with: - api-key: ${{ inputs.infracost-api-key }} + # - name: Setup Infracost + # if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) && fromJSON(inputs.enable-infracost) }} + # uses: infracost/actions/setup@v2 + # with: + # api-key: ${{ inputs.infracost-api-key }} - - name: Generate Infracost diff - if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) && fromJSON(inputs.enable-infracost) }} - shell: bash - run: | - PLAN_FILE="${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }}" - PLAN_FILE_JSON="${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }}.json" + # - name: Generate Infracost diff + # if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) && fromJSON(inputs.enable-infracost) }} + # shell: bash + # run: | + # PLAN_FILE="${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }}" + # PLAN_FILE_JSON="${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }}.json" - cd ${{ inputs.component-path }} - terraform show -json $PLAN_FILE > $PLAN_FILE_JSON + # cd ${{ inputs.component-path }} + # terraform show -json $PLAN_FILE > $PLAN_FILE_JSON - infracost diff \ - --path=$PLAN_FILE_JSON \ - --format=diff \ - --project-name ${{ inputs.stack }}-${{ inputs.component }} \ - --out-file=/tmp/infracost.txt - infracost diff \ - --path=$PLAN_FILE_JSON \ - --format=json \ - --project-name ${{ inputs.stack }}-${{ inputs.component }} \ - --out-file=/tmp/infracost.json + # infracost diff \ + # --path=$PLAN_FILE_JSON \ + # --format=diff \ + # --project-name ${{ inputs.stack }}-${{ inputs.component }} \ + # --out-file=/tmp/infracost.txt + # infracost diff \ + # --path=$PLAN_FILE_JSON \ + # --format=json \ + # --project-name ${{ inputs.stack }}-${{ inputs.component }} \ + # --out-file=/tmp/infracost.json - - if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) && fromJSON(inputs.enable-infracost) && fromJSON(inputs.debug) }} - shell: bash - run: | - cat ${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }}.json - cat /tmp/infracost.txt - cat /tmp/infracost.json + # - if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) && fromJSON(inputs.enable-infracost) && fromJSON(inputs.debug) }} + # shell: bash + # run: | + # cat ${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }}.json + # cat /tmp/infracost.txt + # cat /tmp/infracost.json - - name: Set infracost variables - if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) && fromJSON(inputs.enable-infracost) }} - id: infracost-diff - shell: bash - run: | - if [[ "${{ inputs.enable-infracost }}" == "true" ]]; then - INFRACOST_DIFF_TOTAL_MONTHLY_COST=$(cat /tmp/infracost.json | jq --raw-output .diffTotalMonthlyCost) - INFRACOST_DETAILS_DIFF_BREAKDOWN="$(cat /tmp/infracost.txt | base64 --wrap 0)" - else - INFRACOST_DIFF_TOTAL_MONTHLY_COST="0" - INFRACOST_DETAILS_DIFF_BREAKDOWN="" - fi + # - name: Set infracost variables + # if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) && fromJSON(inputs.enable-infracost) }} + # id: infracost-diff + # shell: bash + # run: | + # if [[ "${{ inputs.enable-infracost }}" == "true" ]]; then + # INFRACOST_DIFF_TOTAL_MONTHLY_COST=$(cat /tmp/infracost.json | jq --raw-output .diffTotalMonthlyCost) + # INFRACOST_DETAILS_DIFF_BREAKDOWN="$(cat /tmp/infracost.txt | base64 --wrap 0)" + # else + # INFRACOST_DIFF_TOTAL_MONTHLY_COST="0" + # INFRACOST_DETAILS_DIFF_BREAKDOWN="" + # fi - echo "infracost_details_diff_breakdown=$INFRACOST_DETAILS_DIFF_BREAKDOWN" >> "$GITHUB_OUTPUT" - echo "infracost_diff_total_monthly_cost=$INFRACOST_DIFF_TOTAL_MONTHLY_COST" >> "$GITHUB_OUTPUT" + # echo "infracost_details_diff_breakdown=$INFRACOST_DETAILS_DIFF_BREAKDOWN" >> "$GITHUB_OUTPUT" + # echo "infracost_diff_total_monthly_cost=$INFRACOST_DIFF_TOTAL_MONTHLY_COST" >> "$GITHUB_OUTPUT" - - name: Post Plan - if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) && fromJSON(inputs.enable-infracost) }} - id: post-plan - shell: bash - run: | - if [[ "${{ inputs.debug }}" == "true" ]]; then - LOG_LEVEL="DEBUG" - else - LOG_LEVEL="INFO" - fi - cd ${{ inputs.component-path }} - tfcmt \ - --config "${{ github.action_path }}/config/atmos_github_summary.yaml" \ - -owner "${{ github.repository_owner }}" \ - -repo "${{ github.event.repository.name }}" \ - -var "target:${{ inputs.stack }}-${{ inputs.component }}" \ - -var "component:${{ inputs.component }}" \ - -var "stack:${{ inputs.stack }}" \ - -var "job:${{ github.job }}" \ - -var "infracost_details_diff_breakdown:${{ steps.infracost-diff.outputs.infracost_details_diff_breakdown }}" \ - -var "infracost_total_monthly_cost:${{ steps.infracost-diff.outputs.infracost_diff_total_monthly_cost }}" \ - --output $GITHUB_STEP_SUMMARY \ - --log-level $LOG_LEVEL \ - plan -- terraform show ${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }} + # - name: Post Plan + # if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) && fromJSON(inputs.enable-infracost) }} + # id: post-plan + # shell: bash + # run: | + # if [[ "${{ inputs.debug }}" == "true" ]]; then + # LOG_LEVEL="DEBUG" + # else + # LOG_LEVEL="INFO" + # fi + # cd ${{ inputs.component-path }} + # tfcmt \ + # --config "${{ github.action_path }}/config/atmos_github_summary.yaml" \ + # -owner "${{ github.repository_owner }}" \ + # -repo "${{ github.event.repository.name }}" \ + # -var "target:${{ inputs.stack }}-${{ inputs.component }}" \ + # -var "component:${{ inputs.component }}" \ + # -var "stack:${{ inputs.stack }}" \ + # -var "job:${{ github.job }}" \ + # -var "infracost_details_diff_breakdown:${{ steps.infracost-diff.outputs.infracost_details_diff_breakdown }}" \ + # -var "infracost_total_monthly_cost:${{ steps.infracost-diff.outputs.infracost_diff_total_monthly_cost }}" \ + # --output $GITHUB_STEP_SUMMARY \ + # --log-level $LOG_LEVEL \ + # plan -- terraform show ${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }} From 680be66195ac87d76bf50dfb1c363e3acfe9edc4 Mon Sep 17 00:00:00 2001 From: Zinovii Dmytriv Date: Thu, 10 Aug 2023 18:49:10 +0300 Subject: [PATCH 53/61] update --- action.yml | 184 +++++++++++++++++++++++++---------------------------- 1 file changed, 88 insertions(+), 96 deletions(-) diff --git a/action.yml b/action.yml index 3372ee1a0..503c7c2e5 100644 --- a/action.yml +++ b/action.yml @@ -160,14 +160,6 @@ runs: echo "plan_file=$PLAN_FILE" >> $GITHUB_OUTPUT echo "plan_file_path=$PLAN_FILE_PATH" >> $GITHUB_OUTPUT - - name: Has Changes - id: has-changes - shell: bash - run: | - echo ${{ steps.atmos-plan.outputs.has_changes }} - echo ${{ fromJSON(steps.atmos-plan.outputs.has_changes) }} - echo ${{ fromJSON(steps.atmos-plan.outputs.has_changes) == false }} - - name: Configure State AWS Credentials if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) }} uses: aws-actions/configure-aws-credentials@v2.2.0 @@ -177,100 +169,100 @@ runs: role-session-name: "atmos-terraform-state-gitops" mask-aws-account-id: "no" - # - name: Store Plan - # if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) }} - # uses: cloudposse/github-action-terraform-plan-storage@v1 - # id: store-plan - # with: - # action: storePlan - # planPath: ${{ steps.atmos-plan.outputs.plan_file }} - # component: ${{ inputs.component }} - # stack: ${{ inputs.stack }} - # tableName: ${{ inputs.terraform-state-table }} - # bucketName: ${{ inputs.terraform-state-bucket }} + - name: Store Plan + if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) }} + uses: cloudposse/github-action-terraform-plan-storage@v1 + id: store-plan + with: + action: storePlan + planPath: ${{ steps.atmos-plan.outputs.plan_file }} + component: ${{ inputs.component }} + stack: ${{ inputs.stack }} + tableName: ${{ inputs.terraform-state-table }} + bucketName: ${{ inputs.terraform-state-bucket }} - # - name: Store Lockfile - # if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) }} - # uses: cloudposse/github-action-terraform-plan-storage@v1 - # with: - # action: storePlan - # planPath: ${{ inputs.component-path}}/.terraform.lock.hcl - # component: ${{ inputs.component }} - # stack: "${{ inputs.stack }}-lockfile" - # tableName: ${{ inputs.terraform-state-table }} - # bucketName: ${{ inputs.terraform-state-bucket }} + - name: Store Lockfile + if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) }} + uses: cloudposse/github-action-terraform-plan-storage@v1 + with: + action: storePlan + planPath: ${{ inputs.component-path}}/.terraform.lock.hcl + component: ${{ inputs.component }} + stack: "${{ inputs.stack }}-lockfile" + tableName: ${{ inputs.terraform-state-table }} + bucketName: ${{ inputs.terraform-state-bucket }} - # - name: Setup Infracost - # if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) && fromJSON(inputs.enable-infracost) }} - # uses: infracost/actions/setup@v2 - # with: - # api-key: ${{ inputs.infracost-api-key }} + - name: Setup Infracost + if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) && fromJSON(inputs.enable-infracost) }} + uses: infracost/actions/setup@v2 + with: + api-key: ${{ inputs.infracost-api-key }} - # - name: Generate Infracost diff - # if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) && fromJSON(inputs.enable-infracost) }} - # shell: bash - # run: | - # PLAN_FILE="${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }}" - # PLAN_FILE_JSON="${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }}.json" + - name: Generate Infracost diff + if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) && fromJSON(inputs.enable-infracost) }} + shell: bash + run: | + PLAN_FILE="${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }}" + PLAN_FILE_JSON="${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }}.json" - # cd ${{ inputs.component-path }} - # terraform show -json $PLAN_FILE > $PLAN_FILE_JSON + cd ${{ inputs.component-path }} + terraform show -json $PLAN_FILE > $PLAN_FILE_JSON - # infracost diff \ - # --path=$PLAN_FILE_JSON \ - # --format=diff \ - # --project-name ${{ inputs.stack }}-${{ inputs.component }} \ - # --out-file=/tmp/infracost.txt - # infracost diff \ - # --path=$PLAN_FILE_JSON \ - # --format=json \ - # --project-name ${{ inputs.stack }}-${{ inputs.component }} \ - # --out-file=/tmp/infracost.json + infracost diff \ + --path=$PLAN_FILE_JSON \ + --format=diff \ + --project-name ${{ inputs.stack }}-${{ inputs.component }} \ + --out-file=/tmp/infracost.txt + infracost diff \ + --path=$PLAN_FILE_JSON \ + --format=json \ + --project-name ${{ inputs.stack }}-${{ inputs.component }} \ + --out-file=/tmp/infracost.json - # - if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) && fromJSON(inputs.enable-infracost) && fromJSON(inputs.debug) }} - # shell: bash - # run: | - # cat ${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }}.json - # cat /tmp/infracost.txt - # cat /tmp/infracost.json + - if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) && fromJSON(inputs.enable-infracost) && fromJSON(inputs.debug) }} + shell: bash + run: | + cat ${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }}.json + cat /tmp/infracost.txt + cat /tmp/infracost.json - # - name: Set infracost variables - # if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) && fromJSON(inputs.enable-infracost) }} - # id: infracost-diff - # shell: bash - # run: | - # if [[ "${{ inputs.enable-infracost }}" == "true" ]]; then - # INFRACOST_DIFF_TOTAL_MONTHLY_COST=$(cat /tmp/infracost.json | jq --raw-output .diffTotalMonthlyCost) - # INFRACOST_DETAILS_DIFF_BREAKDOWN="$(cat /tmp/infracost.txt | base64 --wrap 0)" - # else - # INFRACOST_DIFF_TOTAL_MONTHLY_COST="0" - # INFRACOST_DETAILS_DIFF_BREAKDOWN="" - # fi + - name: Set infracost variables + if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) && fromJSON(inputs.enable-infracost) }} + id: infracost-diff + shell: bash + run: | + if [[ "${{ inputs.enable-infracost }}" == "true" ]]; then + INFRACOST_DIFF_TOTAL_MONTHLY_COST=$(cat /tmp/infracost.json | jq --raw-output .diffTotalMonthlyCost) + INFRACOST_DETAILS_DIFF_BREAKDOWN="$(cat /tmp/infracost.txt | base64 --wrap 0)" + else + INFRACOST_DIFF_TOTAL_MONTHLY_COST="0" + INFRACOST_DETAILS_DIFF_BREAKDOWN="" + fi - # echo "infracost_details_diff_breakdown=$INFRACOST_DETAILS_DIFF_BREAKDOWN" >> "$GITHUB_OUTPUT" - # echo "infracost_diff_total_monthly_cost=$INFRACOST_DIFF_TOTAL_MONTHLY_COST" >> "$GITHUB_OUTPUT" + echo "infracost_details_diff_breakdown=$INFRACOST_DETAILS_DIFF_BREAKDOWN" >> "$GITHUB_OUTPUT" + echo "infracost_diff_total_monthly_cost=$INFRACOST_DIFF_TOTAL_MONTHLY_COST" >> "$GITHUB_OUTPUT" - # - name: Post Plan - # if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) && fromJSON(inputs.enable-infracost) }} - # id: post-plan - # shell: bash - # run: | - # if [[ "${{ inputs.debug }}" == "true" ]]; then - # LOG_LEVEL="DEBUG" - # else - # LOG_LEVEL="INFO" - # fi - # cd ${{ inputs.component-path }} - # tfcmt \ - # --config "${{ github.action_path }}/config/atmos_github_summary.yaml" \ - # -owner "${{ github.repository_owner }}" \ - # -repo "${{ github.event.repository.name }}" \ - # -var "target:${{ inputs.stack }}-${{ inputs.component }}" \ - # -var "component:${{ inputs.component }}" \ - # -var "stack:${{ inputs.stack }}" \ - # -var "job:${{ github.job }}" \ - # -var "infracost_details_diff_breakdown:${{ steps.infracost-diff.outputs.infracost_details_diff_breakdown }}" \ - # -var "infracost_total_monthly_cost:${{ steps.infracost-diff.outputs.infracost_diff_total_monthly_cost }}" \ - # --output $GITHUB_STEP_SUMMARY \ - # --log-level $LOG_LEVEL \ - # plan -- terraform show ${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }} + - name: Post Plan + if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) && fromJSON(inputs.enable-infracost) }} + id: post-plan + shell: bash + run: | + if [[ "${{ inputs.debug }}" == "true" ]]; then + LOG_LEVEL="DEBUG" + else + LOG_LEVEL="INFO" + fi + cd ${{ inputs.component-path }} + tfcmt \ + --config "${{ github.action_path }}/config/atmos_github_summary.yaml" \ + -owner "${{ github.repository_owner }}" \ + -repo "${{ github.event.repository.name }}" \ + -var "target:${{ inputs.stack }}-${{ inputs.component }}" \ + -var "component:${{ inputs.component }}" \ + -var "stack:${{ inputs.stack }}" \ + -var "job:${{ github.job }}" \ + -var "infracost_details_diff_breakdown:${{ steps.infracost-diff.outputs.infracost_details_diff_breakdown }}" \ + -var "infracost_total_monthly_cost:${{ steps.infracost-diff.outputs.infracost_diff_total_monthly_cost }}" \ + --output $GITHUB_STEP_SUMMARY \ + --log-level $LOG_LEVEL \ + plan -- terraform show ${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }} From 75b0d2d9a6649256e302e2dd79dfe67ebe6aefd4 Mon Sep 17 00:00:00 2001 From: Zinovii Dmytriv Date: Thu, 10 Aug 2023 19:18:32 +0300 Subject: [PATCH 54/61] update --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 503c7c2e5..d3720e6cf 100644 --- a/action.yml +++ b/action.yml @@ -243,7 +243,7 @@ runs: echo "infracost_diff_total_monthly_cost=$INFRACOST_DIFF_TOTAL_MONTHLY_COST" >> "$GITHUB_OUTPUT" - name: Post Plan - if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) && fromJSON(inputs.enable-infracost) }} + if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) }} id: post-plan shell: bash run: | From 3726c04189a2138ca5601a74feef22cc2616d377 Mon Sep 17 00:00:00 2001 From: Zinovii Dmytriv Date: Thu, 10 Aug 2023 19:22:19 +0300 Subject: [PATCH 55/61] update --- config/atmos_github_summary.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/atmos_github_summary.yaml b/config/atmos_github_summary.yaml index 7cf172323..16e4ab845 100644 --- a/config/atmos_github_summary.yaml +++ b/config/atmos_github_summary.yaml @@ -13,7 +13,7 @@ templates: ## :x: Plan Failed for `{{.Vars.component}}` in `{{.Vars.stack}}`! {{ end }} {{- if eq .ExitCode 0 }} - ## Plan Succeeded for `{{.Vars.component}}` in `{{.Vars.stack}}` + ## Changes Found for `{{.Vars.component}}` in `{{.Vars.stack}}` {{ if .CreatedResources}}[![create](https://shields.io/badge/PLAN-CREATE-success?style=for-the-badge)](#user-content-create-{{.Vars.stack}}-{{.Vars.component}}){{ end }} {{- if .UpdatedResources }} [![change](https://shields.io/badge/PLAN-CHANGE-important?style=for-the-badge)](#user-content-change-{{.Vars.stack}}-{{.Vars.component}}){{ end }} From c77122c045c6bf332b1babf571d400c3cbc721e2 Mon Sep 17 00:00:00 2001 From: Zinovii Dmytriv Date: Fri, 11 Aug 2023 12:57:11 +0300 Subject: [PATCH 56/61] update --- action.yml | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/action.yml b/action.yml index d3720e6cf..1bd053038 100644 --- a/action.yml +++ b/action.yml @@ -14,10 +14,10 @@ inputs: component-path: description: "The path to the base component. Atmos defines this value as component_path." required: true - plan-file: - description: "Full name of the plan-file to use. If not set plan-file name will be built by pattern '--'. Default: ''" - required: false - default: '' + sha: + description: "Commit SHA to use when building plan file name. Default: ${{ github.sha }}" + required: true + default: ${{ github.sha }} terraform-plan-role: description: "The AWS role to be used to plan Terraform." required: true @@ -134,12 +134,9 @@ runs: id: atmos-plan shell: bash run: | - PLAN_FILE=$(echo "${{ inputs.stack }}-${{ inputs.component }}-${{ github.sha }}.planfile" | sed 's#/#_#g') - if [ "${{ inputs.plan-file }}" != "" ]; then - PLAN_FILE="${{ inputs.plan-file }}" - fi - + PLAN_FILE=$(echo "${{ inputs.stack }}-${{ inputs.component }}-${{ inputs.sha }}.planfile" | sed 's#/#_#g') PLAN_FILE_PATH=$(pwd) + TERRAFORM_OUTPUT=$(ATMOS_BASE_PATH=$GITHUB_WORKSPACE atmos terraform plan ${{ inputs.component }} \ --stack ${{ inputs.stack }} \ -out=$PLAN_FILE_PATH/$PLAN_FILE \ From 074208fa574dabcc5bcad3ece98bb1b96f128853 Mon Sep 17 00:00:00 2001 From: Zinovii Dmytriv Date: Fri, 11 Aug 2023 13:19:54 +0300 Subject: [PATCH 57/61] update --- action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index 1bd053038..ddae9d829 100644 --- a/action.yml +++ b/action.yml @@ -15,9 +15,9 @@ inputs: description: "The path to the base component. Atmos defines this value as component_path." required: true sha: - description: "Commit SHA to use when building plan file name. Default: ${{ github.sha }}" + description: "Commit SHA to use when building plan file name. Default: github.sha" required: true - default: ${{ github.sha }} + default: "${{ github.sha }}" terraform-plan-role: description: "The AWS role to be used to plan Terraform." required: true From 5d9363f676544065ccdb78454e7706fdc192cdf4 Mon Sep 17 00:00:00 2001 From: Zinovii Dmytriv Date: Fri, 11 Aug 2023 17:56:46 +0300 Subject: [PATCH 58/61] update --- action.yml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/action.yml b/action.yml index ddae9d829..6af9d99ad 100644 --- a/action.yml +++ b/action.yml @@ -14,8 +14,8 @@ inputs: component-path: description: "The path to the base component. Atmos defines this value as component_path." required: true - sha: - description: "Commit SHA to use when building plan file name. Default: github.sha" + plan-id: + description: "Suffix that will be used for plan file name to uniquely identify it. Default: github.sha" required: true default: "${{ github.sha }}" terraform-plan-role: @@ -134,7 +134,7 @@ runs: id: atmos-plan shell: bash run: | - PLAN_FILE=$(echo "${{ inputs.stack }}-${{ inputs.component }}-${{ inputs.sha }}.planfile" | sed 's#/#_#g') + PLAN_FILE=$(echo "${{ inputs.stack }}-${{ inputs.component }}-${{ inputs.plan-id }}.planfile" | sed 's#/#_#g') PLAN_FILE_PATH=$(pwd) TERRAFORM_OUTPUT=$(ATMOS_BASE_PATH=$GITHUB_WORKSPACE atmos terraform plan ${{ inputs.component }} \ @@ -144,8 +144,6 @@ runs: -input=false \ -no-color) - echo "$TERRAFORM_OUTPUT" - if echo "$TERRAFORM_OUTPUT" | grep -q '^No changes. Your infrastructure matches the configuration.'; then echo "has_changes=false" >> $GITHUB_OUTPUT echo "No changes" From c644144830d894d33fdc491175a8180e09006ab2 Mon Sep 17 00:00:00 2001 From: Zinovii Dmytriv Date: Fri, 11 Aug 2023 19:44:47 +0300 Subject: [PATCH 59/61] update --- action.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index 6af9d99ad..87853b5e4 100644 --- a/action.yml +++ b/action.yml @@ -166,24 +166,26 @@ runs: - name: Store Plan if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) }} - uses: cloudposse/github-action-terraform-plan-storage@v1 + uses: cloudposse/github-action-terraform-plan-storage@added-commitsha-overwrite-input id: store-plan with: action: storePlan planPath: ${{ steps.atmos-plan.outputs.plan_file }} component: ${{ inputs.component }} stack: ${{ inputs.stack }} + commitSHA: ${{ inputs.plan-id }} tableName: ${{ inputs.terraform-state-table }} bucketName: ${{ inputs.terraform-state-bucket }} - name: Store Lockfile if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) }} - uses: cloudposse/github-action-terraform-plan-storage@v1 + uses: cloudposse/github-action-terraform-plan-storage@added-commitsha-overwrite-input with: action: storePlan planPath: ${{ inputs.component-path}}/.terraform.lock.hcl component: ${{ inputs.component }} stack: "${{ inputs.stack }}-lockfile" + commitSHA: ${{ inputs.plan-id }} tableName: ${{ inputs.terraform-state-table }} bucketName: ${{ inputs.terraform-state-bucket }} From b686a10d839f29792b25eff693737e1ed34f235a Mon Sep 17 00:00:00 2001 From: Zinovii Dmytriv Date: Mon, 14 Aug 2023 18:25:21 +0300 Subject: [PATCH 60/61] update --- README.md | 6 ++++++ action.yml | 6 ------ docs/github-action.md | 6 ++++++ 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 2b7a803ec..1a0025c90 100644 --- a/README.md +++ b/README.md @@ -137,6 +137,7 @@ this action. For more on setting up those components, see the `gitops` component | debug | Enable action debug mode. Default: 'false' | false | false | | enable-infracost | Whether to enable infracost summary. Requires secret `infracost-api-key` to be specified. Default: 'false | false | false | | infracost-api-key | Infracost API key | N/A | false | +| plan-id | Suffix that will be used for plan file name to uniquely identify it. Default: github.sha | ${{ github.sha }} | true | | stack | The stack name for the given component. | N/A | true | | terraform-plan-role | The AWS role to be used to plan Terraform. | N/A | true | | terraform-state-bucket | The S3 Bucket where the planfiles are stored. | N/A | true | @@ -146,6 +147,11 @@ this action. For more on setting up those components, see the `gitops` component | token | Used to pull node distributions for Atmos from Cloud Posse's GitHub repository. Since there's a default, this is typically not supplied by the user. When running this action on github.com, the default value is sufficient. When running on GHES, you can pass a personal access token for github.com if you are experiencing rate limiting. | ${{ github.server\_url == 'https://github.com' && github.token \|\| '' }} | false | +## Outputs + +| Name | Description | +|------|-------------| +| has-changes | Has Changes | diff --git a/action.yml b/action.yml index 87853b5e4..2a72da0f1 100644 --- a/action.yml +++ b/action.yml @@ -60,12 +60,6 @@ inputs: GHES, you can pass a personal access token for github.com if you are experiencing rate limiting. default: ${{ github.server_url == 'https://github.com' && github.token || '' }} outputs: - plan-file-path: - description: Plan File - value: ${{ steps.atmos-plan.outputs.plan_file_path }} - plan-file: - description: Plan File - value: ${{ steps.atmos-plan.outputs.plan_file }} has-changes: description: Has Changes value: ${{ steps.atmos-plan.outputs.has_changes }} diff --git a/docs/github-action.md b/docs/github-action.md index 30196e79f..57768176e 100644 --- a/docs/github-action.md +++ b/docs/github-action.md @@ -11,6 +11,7 @@ | debug | Enable action debug mode. Default: 'false' | false | false | | enable-infracost | Whether to enable infracost summary. Requires secret `infracost-api-key` to be specified. Default: 'false | false | false | | infracost-api-key | Infracost API key | N/A | false | +| plan-id | Suffix that will be used for plan file name to uniquely identify it. Default: github.sha | ${{ github.sha }} | true | | stack | The stack name for the given component. | N/A | true | | terraform-plan-role | The AWS role to be used to plan Terraform. | N/A | true | | terraform-state-bucket | The S3 Bucket where the planfiles are stored. | N/A | true | @@ -20,4 +21,9 @@ | token | Used to pull node distributions for Atmos from Cloud Posse's GitHub repository. Since there's a default, this is typically not supplied by the user. When running this action on github.com, the default value is sufficient. When running on GHES, you can pass a personal access token for github.com if you are experiencing rate limiting. | ${{ github.server\_url == 'https://github.com' && github.token \|\| '' }} | false | +## Outputs + +| Name | Description | +|------|-------------| +| has-changes | Has Changes | From 940538a370304e3639a956485f4c8fd5a0407626 Mon Sep 17 00:00:00 2001 From: Zinovii Dmytriv Date: Tue, 15 Aug 2023 13:07:27 +0300 Subject: [PATCH 61/61] update --- action.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/action.yml b/action.yml index 2a72da0f1..87853b5e4 100644 --- a/action.yml +++ b/action.yml @@ -60,6 +60,12 @@ inputs: GHES, you can pass a personal access token for github.com if you are experiencing rate limiting. default: ${{ github.server_url == 'https://github.com' && github.token || '' }} outputs: + plan-file-path: + description: Plan File + value: ${{ steps.atmos-plan.outputs.plan_file_path }} + plan-file: + description: Plan File + value: ${{ steps.atmos-plan.outputs.plan_file }} has-changes: description: Has Changes value: ${{ steps.atmos-plan.outputs.has_changes }}