Skip to content

Commit

Permalink
Fix tfstate for gitops
Browse files Browse the repository at this point in the history
  • Loading branch information
goruha committed Jul 26, 2024
1 parent 60b657f commit af4bbe6
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,31 +128,31 @@ runs:
- name: Test
shell: bash
run: |
echo "${{ fromJson(steps.component.outputs.settings).enabled == 'true' }}"
echo "${{ fromJson(steps.component.outputs.settings).component-path }}"
- name: Set atmos cli base path vars
if: ${{ fromJson(steps.component.outputs.settings).enabled == 'true' }}
if: ${{ fromJson(steps.component.outputs.settings).enabled }}
shell: bash
run: |-
# Set ATMOS_BASE_PATH allow `cloudposse/utils` provider to read atmos config from the correct path
ATMOS_BASE_PATH="${{ fromJson(steps.component.outputs.settings).base-path }}"
echo "ATMOS_BASE_PATH=$(realpath ${ATMOS_BASE_PATH:-./})" >> $GITHUB_ENV
- name: Install tfcmt
if: ${{ fromJson(steps.component.outputs.settings).enabled == 'true' }}
if: ${{ fromJson(steps.component.outputs.settings).enabled }}
uses: jaxxstorm/[email protected]
with:
repo: suzuki-shunsuke/tfcmt
tag: v4.11.0

- name: Prepare Artifacts Directory
if: ${{ fromJson(steps.component.outputs.settings).enabled == 'true' }}
if: ${{ fromJson(steps.component.outputs.settings).enabled }}
shell: bash
run: |
mkdir -p metadata
- name: Define Job Variables
if: ${{ fromJson(steps.component.outputs.settings).enabled == 'true' }}
if: ${{ fromJson(steps.component.outputs.settings).enabled }}
id: vars
shell: bash
run: |
Expand Down Expand Up @@ -181,7 +181,7 @@ runs:
echo "issue_file=${ISSUE_SUMMARY_FILE}" >> $GITHUB_OUTPUT
- name: Configure Plan AWS Credentials
if: ${{ fromJson(steps.component.outputs.settings).enabled == 'true' }}
if: ${{ fromJson(steps.component.outputs.settings).enabled }}
uses: aws-actions/[email protected]
with:
aws-region: ${{ steps.config.outputs.aws-region }}
Expand All @@ -192,14 +192,14 @@ runs:
- name: Cache .terraform
id: cache
uses: actions/cache@v4
if: ${{ fromJson(steps.component.outputs.settings).enabled == 'true' }}
if: ${{ fromJson(steps.component.outputs.settings).enabled }}
with:
path: |
./${{ steps.vars.outputs.component_path }}/.terraform
key: ${{ steps.vars.outputs.cache-key }}

- name: Atmos Terraform Plan
if: ${{ fromJson(steps.component.outputs.settings).enabled == 'true' }}
if: ${{ fromJson(steps.component.outputs.settings).enabled }}
id: atmos-plan
shell: bash
run: |
Expand Down Expand Up @@ -367,7 +367,7 @@ runs:
- name: Store Component Metadata to Artifacts
if: ${{ fromJson(steps.component.outputs.settings).enabled == 'true' && inputs.drift-detection-mode-enabled == 'true' }}
if: ${{ fromJson(steps.component.outputs.settings).enabled && inputs.drift-detection-mode-enabled == 'true' }}
shell: bash
run: |
echo -n '{ "stack": "${{ inputs.stack }}", "component": "${{ inputs.component }}", "componentPath": "${{ steps.vars.outputs.component_path }}", "drifted": '"${{ steps.atmos-plan.outputs.changes }}"', "error": '"${{ steps.atmos-plan.outputs.error }}"' }' > "metadata/${{ steps.vars.outputs.component_slug }}.metadata.json"
Expand Down Expand Up @@ -411,7 +411,7 @@ runs:
echo "rand=$(openssl rand -hex 5)" >> "$GITHUB_OUTPUT"
- name: Upload Artifacts
if: ${{ fromJson(steps.component.outputs.settings).enabled == 'true' && inputs.drift-detection-mode-enabled == 'true' }}
if: ${{ fromJson(steps.component.outputs.settings).enabled && inputs.drift-detection-mode-enabled == 'true' }}
uses: actions/upload-artifact@v4
with:
# The name of the artifact needs to be unique for every job run!
Expand All @@ -421,7 +421,7 @@ runs:
retention-days: ${{ inputs.metadata-retention-days }}

- name: Exit status
if: ${{ fromJson(steps.component.outputs.settings).enabled == 'true' }}
if: ${{ fromJson(steps.component.outputs.settings).enabled }}
shell: bash
run: |
exit ${{ steps.atmos-plan.outputs.result }}

0 comments on commit af4bbe6

Please sign in to comment.