From e478f6b4644de03e104f505a44f95ff6b8400b4c Mon Sep 17 00:00:00 2001 From: Dougal Rea Date: Wed, 15 May 2024 12:53:48 +0100 Subject: [PATCH 1/3] Add build & deploy workflow --- .github/workflows/build-deploy-fe.yml | 89 +++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 .github/workflows/build-deploy-fe.yml diff --git a/.github/workflows/build-deploy-fe.yml b/.github/workflows/build-deploy-fe.yml new file mode 100644 index 0000000..8e3dd62 --- /dev/null +++ b/.github/workflows/build-deploy-fe.yml @@ -0,0 +1,89 @@ +name: Build & Deploy FE + +on: + workflow_dispatch: + inputs: + account: + description: AWS account to deploy to + required: true + type: choice + options: + - b3tr-dev + default: b3tr-dev + s3_bucket_name: + description: Name of the S3 bucket which stores static FE + required: true + type: string + default: b3tr-dev-insight-fe + cloudfront_distribution_id: + description: ID of the Cloudfront distribution to invalidate + required: true + type: string + default: E38AJF9PZBDTJ6 + workflow_call: + inputs: + account: + description: AWS account to deploy to + required: true + default: b3tr-dev + type: string + s3_bucket_name: + description: Name of the S3 bucket which stores static FE + required: true + type: string + default: b3tr-dev-insight-fe + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }}-deploy-fe + cancel-in-progress: true + +# Required for authentication through GitHub OIDC +permissions: + id-token: write # This is required for requesting the JWT + contents: read # This is required for actions/checkout + +jobs: + deploy: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Node + uses: actions/setup-node@v4 + with: + node-version: '20' + + - name: Install + run: yarn + + - name: Build + run: yarn build + + - name: Determine AWS account ID and role + id: determine-account + # For any account requiring insights depoyment, configure OIDC authentication in that account and update this step accordingly + run: | + case ${{ inputs.account }} in + b3tr-dev) + echo "role_arn=${{ secrets.B3TR_DEV_AWS_ACC_ROLE }}" >> $GITHUB_OUTPUT + ;; + *) + echo "Invalid account specified. Please ensure the OIDC role for the desired account has been added to this repository's secrets." + exit 1 + ;; + esac + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + aws-region: eu-west-1 + role-to-assume: ${{ steps.determine-account.outputs.role_arn }} + + - name: Upload to S3 + run: aws s3 sync ./packages/frontend/dist s3://${{ inputs.s3_bucket_name }} --delete + + - name: Cloudfront Invalidation + run: | + AWS_MAX_ATTEMPTS=10 aws cloudfront create-invalidation --distribution-id ${{ inputs.cloudfront_distribution_id }} --paths '/' '/*' From 749cef8faa625b4e999401596a0667f0ad069b54 Mon Sep 17 00:00:00 2001 From: Dougal Rea Date: Wed, 15 May 2024 12:54:49 +0100 Subject: [PATCH 2/3] Update build-deploy-fe.yml --- .github/workflows/build-deploy-fe.yml | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/.github/workflows/build-deploy-fe.yml b/.github/workflows/build-deploy-fe.yml index 8e3dd62..6ced71d 100644 --- a/.github/workflows/build-deploy-fe.yml +++ b/.github/workflows/build-deploy-fe.yml @@ -20,18 +20,6 @@ on: required: true type: string default: E38AJF9PZBDTJ6 - workflow_call: - inputs: - account: - description: AWS account to deploy to - required: true - default: b3tr-dev - type: string - s3_bucket_name: - description: Name of the S3 bucket which stores static FE - required: true - type: string - default: b3tr-dev-insight-fe concurrency: group: ${{ github.workflow }}-${{ github.ref }}-deploy-fe From 5d40521de3a5e09e54aa8e5052b22fc20999eee2 Mon Sep 17 00:00:00 2001 From: Dougal Rea Date: Wed, 15 May 2024 12:56:32 +0100 Subject: [PATCH 3/3] Update build-deploy-fe.yml --- .github/workflows/build-deploy-fe.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-deploy-fe.yml b/.github/workflows/build-deploy-fe.yml index 6ced71d..4e6e14f 100644 --- a/.github/workflows/build-deploy-fe.yml +++ b/.github/workflows/build-deploy-fe.yml @@ -41,7 +41,7 @@ jobs: - name: Set up Node uses: actions/setup-node@v4 with: - node-version: '20' + node-version: '16' - name: Install run: yarn