From 47a60350dc226b85c75d8b9099a11fbf0a38766a Mon Sep 17 00:00:00 2001 From: Jo Date: Mon, 13 May 2024 08:56:19 -0400 Subject: [PATCH] dynamic frontend bucket --- .github/workflows/deploy-production.yml | 11 ++++++++++- .github/workflows/deploy-staging.yml | 9 ++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy-production.yml b/.github/workflows/deploy-production.yml index 38826f90d..270d9c254 100644 --- a/.github/workflows/deploy-production.yml +++ b/.github/workflows/deploy-production.yml @@ -41,6 +41,8 @@ jobs: if: needs.detect-changes.outputs.deploy-iac == 'true' environment: production runs-on: ubuntu-latest + outputs: + bucket: ${{ steps.output-bucket-name.outputs.bucket }} env: TF_VAR_region: ${{ vars.AWS_REGION }} TF_VAR_environment: ${{ vars.ENV_SHORT_NAME }} @@ -117,6 +119,13 @@ jobs: terragrunt plan -out tfplan terragrunt apply tfplan + - name: output-bucket-name + id: output-bucket-name + working-directory: ./tofu/environments/stage/services/frontend-infra + run: | + output=$(terragrunt output bucket | tr -d '"') + echo bucket=$output >> $GITHUB_OUTPUT + deploy-frontend: needs: - detect-changes @@ -154,7 +163,7 @@ jobs: aws-region: ${{ vars.AWS_REGION }} - name: Deploy frontend to S3 - run: aws s3 sync frontend/dist s3://tb-apmt-prod-frontend + run: aws s3 sync frontend/dist "s3://${{ needs.deploy-iac.outputs.bucket }}" //s3://tb-apmt-prod-frontend deploy-backend: needs: diff --git a/.github/workflows/deploy-staging.yml b/.github/workflows/deploy-staging.yml index e581817c4..83044ff43 100644 --- a/.github/workflows/deploy-staging.yml +++ b/.github/workflows/deploy-staging.yml @@ -121,6 +121,13 @@ jobs: terragrunt plan -out tfplan terragrunt apply tfplan + - name: output-bucket-name + id: output-bucket-name + working-directory: ./tofu/environments/stage/services/frontend-infra + run: | + output=$(terragrunt output bucket | tr -d '"') + echo bucket=$output >> $GITHUB_OUTPUT + deploy-frontend: needs: - detect-changes @@ -158,7 +165,7 @@ jobs: aws-region: ${{ vars.AWS_REGION }} - name: Deploy frontend to S3 - run: aws s3 sync frontend/dist s3://tb-apmt-stg-frontend + run: aws s3 sync frontend/dist "s3://${{ needs.deploy-iac.outputs.bucket }}" //s3://tb-apmt-stg-frontend