Skip to content

Deploy on Production Server #39

Deploy on Production Server

Deploy on Production Server #39

name: Deploy on Production Server
on:
workflow_dispatch:
pull_request:
branches: ["release"]
types: ["closed"]
env:
API_BASE_URL: https://api.knud2024.com/
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Setup NodeJS
uses: actions/setup-node@v4
with:
node-version: 20
- name: Checkout Code
uses: actions/checkout@v4
- name: Setup pnpm package manager
run: npm install -g pnpm
- name: Install Dependencies
run: pnpm install
- name: Build Production
run: pnpm run build
env:
VITE_API_BASE_URL: ${{env.API_BASE_URL}}
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{secrets.AWS_ACCESS_KEY}}
aws-secret-access-key: ${{secrets.AWS_SECRET_ACCESS_KEY}}
aws-region: ap-southeast-2
- name: Upload to AWS S3
env:
BUCKET_NAME: ${{secrets.AWS_BUCKET_NAME}}
run: aws s3 sync ./dist s3://$BUCKET_NAME --delete
- name: Invalidate AWS Cloudfront Cache
run: |
aws cloudfront create-invalidation \
--distribution-id ${{secrets.AWS_CLOUDFRONT_ID}} --paths /*