Skip to content

Commit

Permalink
tinker more
Browse files Browse the repository at this point in the history
  • Loading branch information
LesnyRumcajs committed Jan 17, 2024
1 parent 4a4a459 commit fb0a191
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions composite-action/terragrunt/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,13 @@ inputs:

runs:
using: "composite"
# Use the Bash shell regardless whether the GitHub Actions runner is ubuntu-latest, macos-latest, or windows-latest
defaults:
run:
shell: bash
steps:
# Workaround for https://github.com/orgs/community/discussions/51280
- name: Set TF/TG versions
shell: bash
run: |
echo "tf_version=1.6.6" >> $GITHUB_ENV
echo "tg_version=0.53.2" >> $GITHUB_ENV
Expand All @@ -46,24 +49,22 @@ runs:
uses: hashicorp/setup-terraform@v2
with:
terraform_version: v${{ env.tf_version }}
# This is required for Terragrunt to parse Terraform outputs.
terraform_wrapper: false

- name: Setup Terragrunt
shell: bash
run: |
sudo wget -q -O /bin/terragrunt "https://github.com/gruntwork-io/terragrunt/releases/download/v${{ env.tg_version }}/terragrunt_linux_amd64"
sudo chmod +x /bin/terragrunt
terragrunt -v
- name: Check terragrunt HCL
working-directory: ${{ inputs.working_directory }}
shell: bash
run: |
terragrunt hclfmt --terragrunt-check --terragrunt-diff
- name: Validate
working-directory: ${{ inputs.working_directory }}
shell: bash
run: |
terragrunt validate
env:
Expand All @@ -75,7 +76,6 @@ runs:
id: plan
working-directory: ${{ inputs.working_directory }}
continue-on-error: true
shell: bash
env:
AWS_ACCESS_KEY_ID: ${{ inputs.aws_access_key_id }}
AWS_SECRET_ACCESS_KEY: ${{ inputs.aws_secret_access_key }}
Expand All @@ -88,7 +88,10 @@ runs:
TF_VAR_new_relic_api_key: ${{ inputs.new_relic_api_key }}
TF_VAR_new_relic_account_id: ${{ inputs.new_relic_account_id }}
run: |
terragrunt plan -no-color --terragrunt-non-interactive -out ${{ github.workspace }}/tfplan
terragrunt plan -no-color --terragrunt-non-interactive -out ${{ github.workspace }}/tfplan | tee output
echo 'plan<<EOF' >> $GITHUB_OUTPUT
cat output >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
- name: Find Comment
if: github.event.pull_request.draft == false &&
Expand All @@ -104,7 +107,7 @@ runs:
- name: Create or Update Comment
if: github.event.pull_request.draft == true &&
github.event_name == 'pull_request' &&
!contains(steps.plan.outputs.stdout, 'No changes. Your infrastructure matches the configuration.')
!contains(steps.plan.outputs.plan, 'No changes. Your infrastructure matches the configuration.')
uses: peter-evans/create-or-update-comment@v2
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
Expand All @@ -115,7 +118,7 @@ runs:
<details><summary>Show Plan</summary>
```
${{ steps.plan.outputs.stdout }}
${{ steps.plan.outputs.plan }}
```
</details>
Expand All @@ -125,12 +128,11 @@ runs:
uses: detomarco/delete-comments@v1.0.4
if: github.event.pull_request.draft == true &&
github.event_name == 'pull_request' &&
contains(steps.plan.outputs.stdout, 'No changes. Your infrastructure matches the configuration.')
contains(steps.plan.outputs.plan, 'No changes. Your infrastructure matches the configuration.')
with:
comment-id: ${{ steps.fc.outputs.comment-id }}

- name: Terragrunt Plan Status
shell: bash
if: steps.plan.outcome == 'failure'
run: exit 1

Expand All @@ -144,7 +146,6 @@ runs:
terragrunt destroy -auto-approve --terragrunt-non-interactive
terragrunt apply -auto-approve --terragrunt-non-interactive
fi
shell: bash
working-directory: ${{ inputs.working_directory }}
env:
TF_VAR_do_token: ${{ inputs.do_token }}
Expand All @@ -161,7 +162,6 @@ runs:

- name: Terragrunt Force Apply
if: github.ref == 'refs/heads/main' && github.event_name == 'workflow_dispatch'
shell: bash
working-directory: ${{ inputs.working_directory }}
env:
TF_VAR_do_token: ${{ inputs.do_token }}
Expand Down

0 comments on commit fb0a191

Please sign in to comment.