Skip to content

Commit

Permalink
action and readme
Browse files Browse the repository at this point in the history
  • Loading branch information
mostafa6765 committed Jul 1, 2024
1 parent 9858f17 commit f59e94a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 10 deletions.
24 changes: 19 additions & 5 deletions .github/workflows/terraform-terragrunt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,34 @@ on:
push:
branches:
- main
- stage
- dev
workflow_dispatch: # Triggered manually from GitHub UI

jobs:
terraform:
runs-on: ubuntu-latest
env:
TF_WORKSPACE: terragrunt
# https://terragrunt.gruntwork.io/docs/getting-started/supported-versions/
THE_TG_VERSION: 0.57.0
THE_TF_VERSION: 1.8.0
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set Terraform workspace based on branch
id: set-workspace
run: |
BRANCH_NAME=${GITHUB_REF#refs/heads/}
if [[ "$BRANCH_NAME" == "main" ]]; then
echo "TF_WORKSPACE=prod-project" >> $GITHUB_ENV
elif [[ "$BRANCH_NAME" == "stage-project" ]]; then
echo "TF_WORKSPACE=stage" >> $GITHUB_ENV
elif [[ "$BRANCH_NAME" == "dev-project" ]]; then
echo "TF_WORKSPACE=dev" >> $GITHUB_ENV
else
echo "TF_WORKSPACE=default" >> $GITHUB_ENV
fi
- name: Set up Terraform CLI
uses: hashicorp/setup-terraform@v3
with:
Expand All @@ -39,14 +53,14 @@ jobs:
- name: Terragrunt init
run: |
cd ./environment/stage
cd ./environment/${{ env.TF_WORKSPACE }}
terragrunt init --terragrunt-non-interactive
echo "🔧 Terragrunt init completed!"
- name: Terragrunt plan
run: |
cd ./environment/stage
terragrunt plan --terragrunt-non-interactive
cd ./environment/${{ env.TF_WORKSPACE }}
terragrunt plan --terragrunt-non-interactive
echo "📝 Terragrunt plan completed!"
- name: Display success message
Expand Down
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,17 @@ terrafrom-terragrunt-aws-project
│ ├── common
│ │ └── common-resources.tf
│ ├── stage
│ │ ├── modules (symlink with root modules)
│ │ ├── common-*.tf (symlink with common)
│ │ ├── modules (symlink with root modules via script)
│ │ ├── common-*.tf (symlink with common via script)
│ │ ├── main.tf
│ │ └── variables.tf
│ │ ├── variables.tf
│ │ └── output.tf
│ └── prod
│ ├── modules (symlink with root modules)
│ ├── modules (symlink with root modules via script)
│ ├── common-*.tf (symlink with common)
│ ├── main.tf
│ └── variables.tf
│ ├── variables.tf
│ └── output.tf
└── environment
├── stage
│ └── terragrunt.hcl
Expand Down

0 comments on commit f59e94a

Please sign in to comment.