Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: AWS Deployment #282

Merged
merged 4 commits into from
Mar 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 31 additions & 9 deletions .github/workflows/aws-deploy.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
name: AWS Deploy Example
name: AWS Deployment

on:
workflow_dispatch:
Expand All @@ -26,15 +26,34 @@ 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

- name: Upload build files
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3
with:
name: aws-deploy-files
path: ./dist

deploy:
needs: build
runs-on: ubuntu-latest
ShrimpCryptid marked this conversation as resolved.
Show resolved Hide resolved

# Dynamically set the environment variable based on the input above:
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
Expand All @@ -60,14 +79,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 "/*"
Loading