📋
SaveYourTime
  • SaveYourTime - Coding Notes
  • Front-End
    • Next.js - Set up with TypeScript
  • Backend
    • Install MySQL on Ubuntu
    • Setup Certbot with route53 on Ubuntu 20.04
    • Configure a Nginx HTTPS Reverse Proxy
    • TypeORM - How to seed data with typeorm-seeding 🔥
  • React Native
    • React Native - Facebook Login
    • React Native - Adding a new Swift file and a Bridge header
  • Tools
    • ESLint
    • Prettier
  • Amazon Web Services
    • AWS - Deploy Next.js Application to AWS S3
    • AWS - Deploy Nest.js Server to Elastic Beanstalk
    • AWS - Setup AWS CloudFront
    • AWS - Configure HTTPS for CloudFront with GoDaddy Domain
    • AWS - Configure HTTPS for Elastic Beanstalk Environments with GoDaddy Domain
    • AWS - Fix Next.js static site hosted on S3 CloudFront routing fails on page reload
    • AWS - Running Puppeteer on AWS EC2
    • AWS - Running Metabase on AWS Elastic Beanstalk
  • GitHub Actions
    • Github - Deploying a React Next.js App to AWS S3 with Github Actions
    • Github - Deploying a Nest.js App to AWS Elastic Beanstalk (Docker Platform) with Github Actions
    • Github - Deploying a Nest.js App to AWS Elastic Beanstalk (Node.js Platform) with Github Actions
  • Others
    • Using Fastlane to automate beta deployments and releases for your iOS and Android apps
    • NodeBB
Powered by GitBook
On this page
  • Create a workflow for staging and production instances
  • Setup workflow files
  • Add AWS secrets to Github
  • Push code to Github then Github Action will deploy your app to aws automatically

Was this helpful?

  1. GitHub Actions

Github - Deploying a Nest.js App to AWS Elastic Beanstalk (Docker Platform) with Github Actions

PreviousGithub - Deploying a React Next.js App to AWS S3 with Github ActionsNextGithub - Deploying a Nest.js App to AWS Elastic Beanstalk (Node.js Platform) with Github Actions

Last updated 4 years ago

Was this helpful?

Create a workflow for staging and production instances

Click on Actions tab within the Github repo and then Press on New workflow

You can skip this (Choose a workflow template) and click the Setup a workflow yourself and start from scratch.

Setup workflow files

production.yml

# This is a basic workflow to help you get started with Actions

name: CD

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
  push:
    branches: [master]
  pull_request:
    branches: [master]

# A map of environment variables that are available to all jobs and steps in the workflow
env:
  AWS_ENVIRONMENT_NAME: nest-production
  AWS_DEFAULT_REGION: ap-northeast-1

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
  build:
    # The type of runner that the job will run on
    runs-on: ubuntu-latest

    # Steps represent a sequence of tasks that will be executed as part of the job
    steps:
      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
      - uses: actions/checkout@v2

      - uses: actions/setup-node@v1
        with:
          node-version: '12.x'
          registry-url: 'https://registry.npmjs.org'

      - name: Install
        run: |
          node -v
          yarn -v
          yarn install

      - name: Build
        run: yarn build

      - name: Deploy
        uses: hmanzur/actions-aws-eb@v1.0.0
        with:
          command: 'deploy ${{ env.AWS_ENVIRONMENT_NAME }}'
        env:
          AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
          AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
          AWS_DEFAULT_REGION: ${{ env.AWS_DEFAULT_REGION }}

staging.yml

# This is a basic workflow to help you get started with Actions

name: CD

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
  push:
    branches: [staging]
  pull_request:
    branches: [staging]

# A map of environment variables that are available to all jobs and steps in the workflow
env:
  AWS_ENVIRONMENT_NAME: nest-staging
  AWS_DEFAULT_REGION: ap-northeast-1

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
  build:
    # The type of runner that the job will run on
    runs-on: ubuntu-latest

    # Steps represent a sequence of tasks that will be executed as part of the job
    steps:
      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
      - uses: actions/checkout@v2

      - uses: actions/setup-node@v1
        with:
          node-version: '12.x'
          registry-url: 'https://registry.npmjs.org'

      - name: Install
        run: |
          node -v
          yarn -v
          yarn install

      - name: Build
        run: yarn build

      - name: Deploy
        uses: hmanzur/actions-aws-eb@v1.0.0
        with:
          command: 'deploy ${{ env.AWS_ENVIRONMENT_NAME }}'
        env:
          AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
          AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
          AWS_DEFAULT_REGION: ${{ env.AWS_DEFAULT_REGION }}

Replace AWS_ENVIRONMENT_NAME with your environment of the elastic beanstalk application. Replace AWS_DEFAULT_REGION with the region where you created your elastic beanstalk application.

Add AWS secrets to Github

Push code to Github then Github Action will deploy your app to aws automatically