Skip to content

Instantly share code, notes, and snippets.

@rudin
Last active April 9, 2018 09:56
Show Gist options
  • Save rudin/011534395916ca7119976a0867483928 to your computer and use it in GitHub Desktop.
Save rudin/011534395916ca7119976a0867483928 to your computer and use it in GitHub Desktop.
Create React App - Deploy and Rollback scripts
It's annoying to see the build folder being removed while a new build is being created. Error 500 for as long as the build takes...
Instead of 'build', the 'live' folder is being served to the client.
When the build has succeeded, the 'live' folder is being renamed to 'backup', and the 'build' is being renamed to 'live' to take its place. On rollback, the 'backup' will be put back into place.
"removeBackup": "! test -d backup || rm -r ./backup",
"removeRevoked": "! test -d revoked || rm -r ./revoked",
"renameLiveToBackup": "! test -d live || mv ./live ./backup",
"renameLiveToRevoked": "! test -d live || mv ./live ./revoked",
"renameBackupToLive": "! test -d backup || mv ./backup ./live",
"renameBuildToLive": "mv ./build ./live",
"deploy": "npm run build && npm run removeBackup && npm run renameLiveToBackup && npm run renameBuildToLive",
"rollback": "npm run removeRevoked && npm run renameLiveToRevoked && npm run renameBackupToLive"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment