Build and Deploy to AWS S3 #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Deploy to AWS S3 | |
on: | |
workflow_dispatch: | |
jobs: | |
build-and-deploy: | |
runs-on: ubuntu-latest | |
steps: | |
# Step 1: Check out the code | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
# Step 2: Set up Node.js | |
- name: Setup Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 18 | |
cache: 'npm' | |
registry-url: 'https://registry.npmjs.org' | |
# Step 3: Install dependencies | |
- name: Install dependencies | |
shell: bash | |
run: npm ci --include=dev | |
# Step 4: Build the project | |
- name: Build package | |
shell: bash | |
run: npm run build | |
# Step 5: Zip the build output | |
- name: Create deployment package | |
run: zip -r build.zip ./build | |
# Step 6: Upload to S3 | |
- name: Upload to S3 | |
uses: jakejarvis/s3-sync-action@v1 | |
with: | |
args: --acl public-read --follow-symlinks | |
env: | |
AWS_S3_BUCKET: ${{ secrets.S3_BUCKET_NAME }} | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
AWS_REGION: ${{ secrets.AWS_REGION }} | |
SOURCE_DIR: ./build |