From 3a31e3f0216423e9101ddcb5a79e2f286e39b93a Mon Sep 17 00:00:00 2001 From: Peyton Lee Date: Fri, 22 Mar 2024 14:24:11 -0700 Subject: [PATCH 1/4] feat: Replaces placeholder S3 build with actual build --- .github/workflows/aws-deploy.yml | 37 +++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/.github/workflows/aws-deploy.yml b/.github/workflows/aws-deploy.yml index 44c65834a..74a3002c1 100644 --- a/.github/workflows/aws-deploy.yml +++ b/.github/workflows/aws-deploy.yml @@ -26,6 +26,26 @@ permissions: contents: write # Required for actions/checkout and OIDC tokens jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 + + - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 + with: + node-version: "18" + + - name: Install and Build + run: npm ci && npx vite build --base=/nucmorph-colorizer/main/ + + - name: Upload build files + uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 + with: + name: aws-deploy-files + path: ./dist + deploy: runs-on: ubuntu-latest @@ -33,8 +53,6 @@ jobs: environment: ${{ github.event.inputs.environment }} steps: - - name: Checkout - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # Compute a short sha for use in the OIDC session name, which has a 64 character limit - name: Add SHORT_SHA env property with commit short sha @@ -60,14 +78,17 @@ jobs: echo "Invalid environment specified" exit 1 fi - - # the src/assets directory below was chosen arbitrarily for demonstration purposes and should be replaced - # with the actual directory containing the files to be uploaded to S3 - # + + - name: Download build artifacts + uses: actions/download-artifact@c850b930e6ba138125429b7e5c93fc707a7f8427 + with: + name: aws-deploy-files + path: ./dist + # Note that the command below will copy the files to the root of the S3 bucket e.g., s3://timelapse.allencell.org/ # If you want to copy files to a S3 prefix / subdirectory, you would want something like ${{ env.S3_BUCKET }}/your_prefix below - - name: Sync an arbitrary directory to S3 - just to demonstrate how. - run: aws s3 sync src/assets ${{ env.S3_BUCKET }} + - name: Copy build files to S3 root + run: aws s3 sync ./dist ${{ env.S3_BUCKET }} - name: Invalidate CloudFront cache run: aws cloudfront create-invalidation --distribution-id ${{ env.CLOUDFRONT_DISTRIBUTION_ID }} --paths "/*" \ No newline at end of file From cb712068dc5c25eb3f02b4acd17c541d5865670f Mon Sep 17 00:00:00 2001 From: Peyton Lee Date: Fri, 22 Mar 2024 14:26:44 -0700 Subject: [PATCH 2/4] rename: Renamed AWS Deployment action --- .github/workflows/aws-deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/aws-deploy.yml b/.github/workflows/aws-deploy.yml index 74a3002c1..49550670f 100644 --- a/.github/workflows/aws-deploy.yml +++ b/.github/workflows/aws-deploy.yml @@ -1,5 +1,5 @@ --- -name: AWS Deploy Example +name: AWS Deployment on: workflow_dispatch: From 4d308bea25f593b4b730d931118f8d770a95c089 Mon Sep 17 00:00:00 2001 From: Peyton Lee Date: Fri, 22 Mar 2024 14:48:32 -0700 Subject: [PATCH 3/4] fix: Removed vite build path --- .github/workflows/aws-deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/aws-deploy.yml b/.github/workflows/aws-deploy.yml index 49550670f..94b423719 100644 --- a/.github/workflows/aws-deploy.yml +++ b/.github/workflows/aws-deploy.yml @@ -38,7 +38,7 @@ jobs: node-version: "18" - name: Install and Build - run: npm ci && npx vite build --base=/nucmorph-colorizer/main/ + run: npm ci && npx vite build - name: Upload build files uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 From 40fb10467198cff57b3ff91f830260e6aff773c0 Mon Sep 17 00:00:00 2001 From: Peyton Lee Date: Fri, 22 Mar 2024 14:59:45 -0700 Subject: [PATCH 4/4] fix: Run deployment step only after build --- .github/workflows/aws-deploy.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/aws-deploy.yml b/.github/workflows/aws-deploy.yml index 94b423719..1b0a83577 100644 --- a/.github/workflows/aws-deploy.yml +++ b/.github/workflows/aws-deploy.yml @@ -47,6 +47,7 @@ jobs: path: ./dist deploy: + needs: build runs-on: ubuntu-latest # Dynamically set the environment variable based on the input above: