Skip to content

action

action #13

name: Terraform Terragrunt Action
on:
push:
branches:
- main
workflow_dispatch: # Triggered manually from GitHub UI
jobs:
terraform:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Print HOME directory
run: |
echo "The HOME directory is: $HOME"
ls -la $HOME
- name: Set up Terraform CLI
uses: hashicorp/setup-terraform@v1
with:
terraform_version: 1.8.0 # Replace with your desired version
- name: Set up Terragrunt CLI
run: |
wget -qO /tmp/terragrunt https://github.com/gruntwork-io/terragrunt/releases/download/v0.57.0/terragrunt_linux_amd64
sudo chmod +x /tmp/terragrunt
sudo mv /tmp/terragrunt /usr/local/bin/terragrunt
echo "✅ Terragrunt CLI setup completed!"
- name: Create Terraform CLI config directory and credentials file
run: |
mkdir $HOME/.terraform.d
cd $HOME/.terraform.d
touch credentials.tfrc.json
chmod 777 credentials.tfrc.json
echo "{\"credentials\": {\"app.terraform.io\": {\"token\": \"${{ secrets.TF_API_TOKEN }}\"}}}" > credentials.tfrc.json
sudo cat credentials.tfrc.json
tree $HOME/.terraform.d
echo "✅ Terraform CLI config directory created!"
- name: Run symlink-modules.sh and select workspace
run: |
./symlink-modules.sh
terragrunt workspace select terragrunt
echo "🔗 Symlink modules and workspace selection completed!"
- name: Terragrunt init
run: |
cd ./environment/stage
terragrunt init
echo "🔧 Terragrunt init completed!"
- name: Terragrunt plan
run: |
cd ./environment/stage
terragrunt plan -out=tfplan
echo "📝 Terragrunt plan completed!"
- name: Display success message
if: github.event_name == 'workflow_dispatch'
run: |
echo "🚀 Terraform Terragrunt Action triggered manually!"