Skip to content

Commit

Permalink
fix: streamline output handling and control flow in Terraform Validat…
Browse files Browse the repository at this point in the history
…e action
  • Loading branch information
arnol377 committed Mar 27, 2025
1 parent 6047eb2 commit 4cd6dd7
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ runs:
if [[ $VALIDATE_EXIT_CODE -ne 0 ]]; then
echo "Terraform validation failed"
echo "is_valid=false" >> $GITHUB_OUTPUT
exit $VALIDATE_EXIT_CODE
else
echo "Terraform validation passed"
echo "is_valid=true" >> $GITHUB_OUTPUT
Expand All @@ -57,7 +56,6 @@ runs:
- name: Terraform Test
id: test
shell: bash
if: steps.validate.outcome == 'success'
run: |
cd ${{ inputs.working-directory }}
terraform test
Expand All @@ -70,9 +68,10 @@ runs:
echo "tests_passed=true" >> $GITHUB_OUTPUT
fi
- name: Set Outputs
- name: Set Final Outputs
id: set_outputs
shell: bash
run: |
echo "is_valid=$(cat $GITHUB_OUTPUT | grep is_valid | cut -d= -f2)" >> $GITHUB_OUTPUT
echo "tests_passed=$(cat $GITHUB_OUTPUT | grep tests_passed | cut -d= -f2)" >> $GITHUB_OUTPUT
echo "is_valid=${{ steps.validate.outputs.is_valid || 'false' }}" >> $GITHUB_OUTPUT
echo "tests_passed=${{ steps.test.outputs.tests_passed || 'false' }}" >> $GITHUB_OUTPUT
echo "stdout=Successfully ran terraform validate and test" >> $GITHUB_OUTPUT

0 comments on commit 4cd6dd7

Please sign in to comment.