4141 value : ${{ jobs.infra.outputs.CF_DOMAIN }}
4242 CF_DISTRIBUTION_ID :
4343 value : ${{ jobs.infra.outputs.CF_DISTRIBUTION_ID }}
44-
4544
46-
47-
4845env :
49- TG_VERSION : 0.55.2
50- TF_VERSION : 1.5.3
51- TG_SRC_PATH : terraform/${{ inputs.working_directory }}
52- AWS_REGION : ca-central-1
46+ TG_VERSION : 0.63.6
47+ TF_VERSION : 1.12.2
48+ TG_SRC_PATH : terraform/${{ inputs.working_directory }}
49+ AWS_REGION : ca-central-1
5350permissions :
5451 id-token : write # This is required for requesting the JWT
5552 contents : write # This is required for actions/checkout
@@ -66,92 +63,80 @@ jobs:
6663 steps :
6764 - name : Checkout
6865 uses : actions/checkout@v4
69-
7066 - name : Configure AWS Credentials
7167 uses : aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # v4
7268 with :
7369 role-to-assume : ${{ secrets.AWS_DEPLOY_ROLE_ARN }}
7470 role-session-name : ${{ inputs.environment_name }}-deployment
7571 aws-region : ${{ env.AWS_REGION }}
76-
7772 - uses : hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd # v3
7873 with :
7974 terraform_version : ${{ env.TF_VERSION }}
80-
81- - name : Setup Terragrunt
82- uses : autero1/action-terragrunt@aefb0a43c4f5503a91fefb307745c4d51c26ed0e # v3
83- with :
84- terragrunt-version : ${{ env.TG_VERSION }}
85-
8675 - name : Get ECR Registry
87- if : inputs.app_env == 'prod'
8876 id : ecr-check
8977 run : |
9078 ECR_REGISTRY=$(aws sts get-caller-identity --query Account --output text).dkr.ecr.ca-central-1.amazonaws.com
9179 echo "ecr-registry=$ECR_REGISTRY" >> $GITHUB_OUTPUT
92-
9380 - name : Image Tags
9481 id : image-tags
9582 shell : bash
9683 run : |
97- if [[ "${{ inputs.app_env }}" == "prod" && "${{ inputs.working_directory }}" == "api" ]]; then
98- API_IMAGE="${{ steps.ecr-check.outputs.ecr-registry }}/${{ github.event.repository.name }}-backend-prod:${{ inputs.tag }}"
99- FLYWAY_IMAGE="${{ steps.ecr-check.outputs.ecr-registry }}/${{ github.event.repository.name }}-migrations-prod:${{ inputs.tag }}"
100- else
101- API_IMAGE="ghcr.io/${{ github.repository }}/backend:${{ inputs.tag }}"
102- FLYWAY_IMAGE="ghcr.io/${{ github.repository }}/migrations:${{ inputs.tag }}"
103- fi
84+ API_IMAGE="${{ steps.ecr-check.outputs.ecr-registry }}/${{ github.repository }}:backend-${{ inputs.tag }}"
85+ FLYWAY_IMAGE="${{ steps.ecr-check.outputs.ecr-registry }}/${{ github.repository }}:migrations-${{ inputs.tag }}"
10486 echo "api-image=$API_IMAGE" >> $GITHUB_OUTPUT
10587 echo "flyway-image=$FLYWAY_IMAGE" >> $GITHUB_OUTPUT
88+
89+ - name : Setup Terragrunt
90+ uses : autero1/action-terragrunt@aefb0a43c4f5503a91fefb307745c4d51c26ed0e # v3
91+ with :
92+ terragrunt-version : ${{ env.TG_VERSION }}
10693 - name : Terragrunt ${{inputs.command}}
10794 working-directory : terraform/${{ inputs.working_directory }}/${{ inputs.environment_name }}
10895 env :
109- target_env : ${{ inputs.environment_name }}
110- aws_license_plate : ${{ secrets.AWS_LICENSE_PLATE }}
111- flyway_image : ${{ steps.image-tags.outputs.flyway -image }}
112- api_image : ${{ steps.image-tags.outputs.api -image }}
113- app_env : ${{inputs.app_env}}
114- stack_prefix : ${{ inputs.stack_prefix }}
115- repo_name : ${{ github.event.repository.name }}
96+ target_env : ${{ inputs.environment_name }}
97+ aws_license_plate : ${{ secrets.AWS_LICENSE_PLATE }}
98+ api_image : ${{ steps.image-tags.outputs.api -image }}
99+ flyway_image : ${{ steps.image-tags.outputs.flyway -image }}
100+ app_env : ${{inputs.app_env}}
101+ stack_prefix : ${{ inputs.stack_prefix }}
102+ repo_name : ${{ github.event.repository.name }}
116103 run : |
117- # Run terraform
118- terragrunt run-all ${{inputs.command}} --terragrunt-non-interactive
119-
104+ # Run terraform
105+ terragrunt run-all ${{inputs.command}} --terragrunt-non-interactive
120106 - name : Terragrunt API Outputs
121- if : ( inputs.working_directory == 'api' && inputs.command == 'apply' )
107+ if : (inputs.working_directory == 'api' && inputs.command == 'apply')
122108 working-directory : terraform/${{ inputs.working_directory }}/${{ inputs.environment_name }}
123109 id : tg-outputs
124110 env :
125- target_env : ${{ inputs.environment_name }}
126- aws_license_plate : ${{ secrets.AWS_LICENSE_PLATE }}
127- flyway_image : ${{ steps.image-tags.outputs.flyway -image }}
128- api_image : ${{ steps.image-tags.outputs.api -image }}
129- app_env : ${{inputs.app_env}}
130- stack_prefix : ${{ inputs.stack_prefix }}
131- repo_name : ${{ github.event.repository.name }}
111+ target_env : ${{ inputs.environment_name }}
112+ aws_license_plate : ${{ secrets.AWS_LICENSE_PLATE }}
113+ api_image : ${{ steps.image-tags.outputs.api -image }}
114+ flyway_image : ${{ steps.image-tags.outputs.flyway -image }}
115+ app_env : ${{inputs.app_env}}
116+ stack_prefix : ${{ inputs.stack_prefix }}
117+ repo_name : ${{ github.event.repository.name }}
132118 run : |
133- terragrunt output -json > outputs.json
134- #print the output
135- cat outputs.json
136- echo "API_GW_URL=$(jq -r .apigw_url.value outputs.json)" >> $GITHUB_OUTPUT
137-
119+ terragrunt output -json > outputs.json
120+ #print the output
121+ cat outputs.json
122+ echo "API_GW_URL=$(jq -r .apigw_url.value outputs.json)" >> $GITHUB_OUTPUT
138123 - name : Terragrunt Frontend Outputs
139- if : ( inputs.working_directory == 'frontend' && inputs.command == 'apply' )
124+ if : (inputs.working_directory == 'frontend' && inputs.command == 'apply')
140125 working-directory : terraform/${{ inputs.working_directory }}/${{ inputs.environment_name }}
141126 id : tg-outputs-frontend
142127 env :
143- target_env : ${{ inputs.environment_name }}
144- aws_license_plate : ${{ secrets.AWS_LICENSE_PLATE }}
145- flyway_image : ${{ steps.image-tags.outputs.flyway -image }}
146- api_image : ${{ steps.image-tags.outputs.api -image }}
147- app_env : ${{inputs.app_env}}
148- stack_prefix : ${{ inputs.stack_prefix }}
149- repo_name : ${{ github.event.repository.name }}
128+ target_env : ${{ inputs.environment_name }}
129+ aws_license_plate : ${{ secrets.AWS_LICENSE_PLATE }}
130+ api_image : ${{ steps.image-tags.outputs.api -image }}
131+ flyway_image : ${{ steps.image-tags.outputs.flyway -image }}
132+ app_env : ${{inputs.app_env}}
133+ stack_prefix : ${{ inputs.stack_prefix }}
134+ repo_name : ${{ github.event.repository.name }}
150135 run : |
151- terragrunt output -json > outputs.json
152- #print the output
153- cat outputs.json
154-
155- echo "S3_BUCKET_ARN=$(jq -r .s3_bucket_arn.value outputs.json)" >> $GITHUB_OUTPUT
156- echo "CF_DOMAIN=$(jq -r .cloudfront.value.domain_name outputs.json)" >> $GITHUB_OUTPUT
157- echo "CF_DISTRIBUTION_ID=$(jq -r .cloudfront.value.distribution_id outputs.json)" >> $GITHUB_OUTPUT
136+ terragrunt output -json > outputs.json
137+ #print the output
138+ cat outputs.json
139+
140+ echo "S3_BUCKET_ARN=$(jq -r .s3_bucket_arn.value outputs.json)" >> $GITHUB_OUTPUT
141+ echo "CF_DOMAIN=$(jq -r .cloudfront.value.domain_name outputs.json)" >> $GITHUB_OUTPUT
142+ echo "CF_DISTRIBUTION_ID=$(jq -r .cloudfront.value.distribution_id outputs.json)" >> $GITHUB_OUTPUT
0 commit comments