-
-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added input.plan-id
and output.has-changes
#19
Open
zdmytriv
wants to merge
61
commits into
main
Choose a base branch
from
added-outputs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
61 commits
Select commit
Hold shift + click to select a range
03db546
update
zdmytriv 8dba22d
update
zdmytriv bfc926c
update
zdmytriv 51028a5
update
zdmytriv 0760bdb
update
zdmytriv c4ca3d2
update
zdmytriv 758d7f6
update
zdmytriv f25a909
update
zdmytriv e029db4
update
zdmytriv 2d19d9d
update
zdmytriv e311916
update
zdmytriv 3a788d7
update
zdmytriv bc60da7
update
zdmytriv 2fdb804
update
zdmytriv 982a4e2
update
zdmytriv 5dd0740
update
zdmytriv 6c4749d
update
zdmytriv 7dd84ad
update
zdmytriv 3a67818
update
zdmytriv 0cc1fb7
update
zdmytriv 8f5df1d
update
zdmytriv b914725
update
zdmytriv 9f58bc1
update
zdmytriv 217a6d9
update
zdmytriv 45ad1fc
update
zdmytriv c0afc5a
update
zdmytriv 2691228
update
zdmytriv 0a61e63
update
zdmytriv a8241eb
update
zdmytriv 84edc5d
update
zdmytriv b2726f9
update
zdmytriv e4661d4
update
zdmytriv 0fbb4ec
update
zdmytriv 1082e8c
update
zdmytriv 6d10f5e
update
zdmytriv bae76f2
update
zdmytriv ebfc00d
update
zdmytriv f891bdf
update
zdmytriv e2fbe5e
update
zdmytriv 0db0946
update
zdmytriv 6f8650c
update
zdmytriv 4e0af4f
update
zdmytriv 5592aca
update
zdmytriv e7810d7
update
zdmytriv ea77bf4
update
zdmytriv bb66c42
update
zdmytriv e8889f3
update
zdmytriv 98a9e7f
update
zdmytriv abbc8fa
update
zdmytriv 11f7328
update
zdmytriv 7962317
update
zdmytriv 6df5e0e
update
zdmytriv 680be66
update
zdmytriv 75b0d2d
update
zdmytriv 3726c04
update
zdmytriv c77122c
update
zdmytriv 074208f
update
zdmytriv 5d9363f
update
zdmytriv c644144
update
zdmytriv b686a10
update
zdmytriv 940538a
update
zdmytriv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,10 @@ inputs: | |
component-path: | ||
description: "The path to the base component. Atmos defines this value as component_path." | ||
required: true | ||
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: | ||
description: "The AWS role to be used to plan Terraform." | ||
required: true | ||
|
@@ -55,6 +59,16 @@ 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 }} | ||
has-changes: | ||
description: Has Changes | ||
value: ${{ steps.atmos-plan.outputs.has_changes }} | ||
|
||
runs: | ||
using: "composite" | ||
|
@@ -83,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: | | ||
|
@@ -120,17 +134,29 @@ 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 }}-${{ inputs.plan-id }}.planfile" | sed 's#/#_#g') | ||
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 | ||
-lock=false \ | ||
-input=false \ | ||
-no-color) | ||
|
||
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 "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) }} | ||
if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) }} | ||
uses: aws-actions/[email protected] | ||
with: | ||
aws-region: ${{ inputs.aws-region }} | ||
|
@@ -139,36 +165,38 @@ runs: | |
mask-aws-account-id: "no" | ||
|
||
- name: Store Plan | ||
if: ${{ fromJSON(steps.settings.outputs.actions_enabled) }} | ||
uses: cloudposse/github-action-terraform-plan-storage@v1 | ||
if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) }} | ||
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) }} | ||
uses: cloudposse/github-action-terraform-plan-storage@v1 | ||
if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) }} | ||
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 }} | ||
|
||
- name: Setup Infracost | ||
if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && 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: ${{ fromJSON(steps.settings.outputs.actions_enabled) && 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="${{ steps.atmos-plan.outputs.plan_file_path }}/${{ steps.atmos-plan.outputs.plan_file }}" | ||
|
@@ -188,15 +216,15 @@ 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(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) }} | ||
if: ${{ fromJSON(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) && fromJSON(inputs.enable-infracost) }} | ||
id: infracost-diff | ||
shell: bash | ||
run: | | ||
|
@@ -212,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(steps.settings.outputs.actions_enabled) && fromJSON(steps.atmos-plan.outputs.has_changes) }} | ||
id: post-plan | ||
shell: bash | ||
run: | | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"@added-commitsha-overwrite-input" isnunclear why that version change is needed. If you can move those bits to a different pr, i'm happy to get the other bits moving