Daksh Gautam's Blog

Setting up Github actions for blog deployment

May 21, 2023

S3 concurrent request exception

  • There is a limit to number of concurrent downloads from S3 bucket. Here is the blog post that talks about this.

Basic template for Github actions

Template includes

  • Running npm install & npm run build
  • Move the build folder to S3.
  • Run cache invalidation
name: AWS S3 Static Deployment
on:
  push:
    branches:
      - master
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v2
      - name: Setup Node
        uses: actions/setup-node@v3
        with:
          node-version: "14.16.1"
      - name: Build
        run: |
          npm install && npm run build
      - name: Configure AWS Credentials
        uses: aws-actions/configure-aws-credentials@v1
        with:
          aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
          aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
          aws-region: us-east-1
      - name: Deploy to S3
        run: aws s3 sync public s3://${{ secrets.AWS_S3_BUCKET }} --delete
      - name: Invalidate Cloudfront
        run: aws cloudfront create-invalidation --distribution-id ${{ secrets.CLOUDFRONT_DIST_ID}} --paths "/*"
  • Add secrets in the repo settings.

© 2023, Love you Papa, Mummy & Amma. ❤️