Skip to content

feat: add content-encoding header #6

feat: add content-encoding header

feat: add content-encoding header #6

# This is a basic workflow to help you get started with Actions
name: FrontEnd deploy
# Controls when the workflow will run
on:
push:
branches: ["FE/noBE"]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
build:
runs-on: ubuntu-latest
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: "18"
- name: Check Node v
run: node -v
- name: Install dependencies
working-directory: ./front
run: npm install
- name: Generate build
working-directory: ./front
run: npm run build
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ap-northeast-2
- name: Upload to S3
env:
BUCKET_NAME: ${{ secrets.AWS_S3_BUCKET_NAME}}
run: |
aws s3 sync \
./front/dist s3://$BUCKET_NAME --delete \
aws s3 sync ./front/dist s3://$BUCKET_NAME --exclude '*' --include '*.js.gz' --content-encoding 'gzip' --content-type 'application/javascript' --acl 'public-read' \
aws s3 sync ./front/dist s3://$BUCKET_NAME --exclude '*' --include '*.svg.gz' --content-encoding 'gzip' --content-type 'image/svg+xml' --acl 'public-read' \
aws s3 sync ./front/dist s3://$BUCKET_NAME --exclude '*' --include '*.ico.gz' --content-encoding 'gzip' --content-type 'image/x-icon' --acl 'public-read' \
aws s3 sync ./front/dist s3://$BUCKET_NAME --exclude '*' --include '*.ttf.gz' --content-encoding 'gzip' --content-type 'font/ttf' --acl 'public-read' \
aws s3 sync ./front/dist s3://$BUCKET_NAME --exclude '*' --include '*.mp3.gz' --content-encoding 'gzip' --content-type 'audio/mpeg' --acl 'public-read'
- name: CloudFront Invalidation
env:
CLOUD_FRONT_ID: ${{ secrets.AWS_CLOUDFRONT_ID}}
run: |
aws cloudfront create-invalidation \
--distribution-id $CLOUD_FRONT_ID --paths '/*'