Skip to content

Commit

Permalink
add github action for building and deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
andyautida14 committed Oct 27, 2023
1 parent a0b9b6f commit d36bf5a
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Build and Deploy
on:
push:
branches:
- main
env:
AWS_DEFAULT_REGION: 'ap-southeast-1'
BUILD_DIR: ./_site
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 18
- name: Install dependencies
run: npm install
- name: Build pages
run: npm build
- name: Upload to S3
run: aws s3 sync $BUILD_DIR $WEBSITE_S3
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
WEBSITE_S3: ${{ secrets.WEBSITE_S3 }}
- name: Create Invalidation
run: aws cloudfront create-invalidation --distribution-id $WEBSITE_DISTRIBUTION_ID --paths '/*'
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
WEBSITE_DISTRIBUTION_ID: ${{ secrets.WEBSITE_DISTRIBUTION_ID }}

0 comments on commit d36bf5a

Please sign in to comment.