Skip to content

Add compression

Add compression #7

Workflow file for this run

# Controls when the action will run. Invokes the workflow on push events but only for the main branch
name: Deploy Website to S3
on:
pull_request:
branches:
- main
env:
AWS_REGION: us-west-1
# Permission can be added at job level or workflow level
permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout
jobs:
AssumeRoleAndCallIdentity:
runs-on: ubuntu-latest
steps:
# Step 1: Checkout the repository
- name: Git clone the repository
uses: actions/checkout@v3
# Step 2: Set up Node.js (for Vite)
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '16' # Use the Node.js version your project requires
# Step 3: Install dependencies (this installs Vite and other dependencies)
- name: Install dependencies
run: npm install
# Step 4: Build the project with Vite
- name: Build project
run: npm run build # This command will generate the ./dist folder
# Step 5: Configure AWS credentials
- name: configure aws credentials
uses: aws-actions/configure-aws-credentials@v1.7.0
with:
role-to-assume: arn:aws:iam::514531162242:role/GitHubAction-AssumeRoleWithAction
role-session-name: GitHub_to_AWS_via_FederatedOIDC
aws-region: ${{ env.AWS_REGION }}
# Step 6: Verify AWS connection (optional)
- name: Sts GetCallerIdentity
run: |
aws sts get-caller-identity
# Step 7: Sync files to S3 (this step will sync only the ./dist folder)
- name: Sync files to S3
run: |
# Sync original and compressed files
aws s3 sync ./dist s3://rsgoshen.us --delete --exclude "*.gz" --exclude "*.br"
# Upload .gz files with Content-Encoding set to gzip
aws s3 cp dist s3://your-s3-bucket-name --recursive --exclude "*" --include "*.gz" \
--content-encoding gzip --metadata-directive REPLACE
# Upload .br files with Content-Encoding set to br
aws s3 cp dist s3://your-s3-bucket-name --recursive --exclude "*" --include "*.br" \
--content-encoding br --metadata-directive REPLACE