Fixed secret #41
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Terraform Terragrunt Action | |
on: | |
push: | |
branches: | |
- main | |
- stage | |
- dev | |
workflow_dispatch: | |
jobs: | |
terraform: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Extract and uppercase branch name | |
id: vars | |
run: | | |
BRANCH_NAME=${GITHUB_REF#refs/heads/} | |
UPPER_BRANCH_NAME=${BRANCH_NAME^^} | |
echo "UPPER_BRANCH_NAME=${UPPER_BRANCH_NAME}" >> $GITHUB_ENV | |
echo "TG_WORKSPACE_KEY=${UPPER_BRANCH_NAME}_TF_WORKSPACE" >> $GITHUB_ENV | |
echo "TG_WORKDIR_KEY=${UPPER_BRANCH_NAME}_TG_WORKDIR" >> $GITHUB_ENV | |
- name: Set up Terraform CLI | |
uses: hashicorp/setup-terraform@v3 | |
with: | |
terraform_version: ${{ secrets['THE_TF_VERSION'] }} | |
terraform_wrapper: true | |
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }} | |
- name: Set up Terragrunt CLI | |
run: | | |
wget -qO /tmp/terragrunt https://github.com/gruntwork-io/terragrunt/releases/download/v${{ secrets['THE_TG_VERSION'] }}/terragrunt_linux_amd64 | |
sudo chmod +x /tmp/terragrunt | |
sudo mv /tmp/terragrunt /usr/local/bin/terragrunt | |
echo "✅ Terragrunt CLI setup completed!" | |
- name: Set Terraform workspace and Terragrunt working directory | |
run: | | |
echo "TF_WORKSPACE=${{ secrets[env.TG_WORKSPACE_KEY] }}" >> $GITHUB_ENV | |
echo "TG_WORKDIR=${{ secrets[env.TG_WORKDIR_KEY] }}" >> $GITHUB_ENV | |
- name: Terragrunt init | |
run: | | |
cd ${{ github.workspace }}/$TG_WORKDIR | |
terragrunt init --terragrunt-non-interactive | |
echo "🔧 Terragrunt init completed!" | |
- name: Terragrunt plan | |
run: | | |
cd ${{ github.workspace }}/$TG_WORKDIR | |
terragrunt plan --terragrunt-non-interactive | |
echo "📝 Terragrunt plan completed!" | |
- name: Display success message | |
if: github.event_name == 'workflow_dispatch' | |
run: | | |
echo "🚀 Terraform Terragrunt Action triggered manually!" |