Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@chriskuech
Created April 5, 2019 04:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chriskuech/8b961b7110ba9b346e03fab8d8ff0ff4 to your computer and use it in GitHub Desktop.
Save chriskuech/8b961b7110ba9b346e03fab8d8ff0ff4 to your computer and use it in GitHub Desktop.
Elastic Beanstalk NodeJS deployment script
#!/bin/bash
# ensure there are no uncommitted changes
git diff-index --quiet HEAD -- || { echo "Untracked changes" >&2; exit 1; }
# derive variables
branch="$(git symbolic-ref --short HEAD)"
timestamp="$(date +%Y%m%dT%H%M%S)"
# do work on a separate branch
git checkout -b "deploy/$timestamp" &&
# build the app
yarn build &&
# force checkin the build
git add ./.next --force &&
git commit -am "Adding production build" &&
# deploy the branch (uses git under the hood)
eb deploy "prod" &&
echo "Deployment completed successfully"
# switch back to main branch
git checkout $branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment