Fulminate Deploy
@fulminate/deploy is an easy to use package that allows your server to listen to hooks incoming from your VCS and execute automated code update for your projects.
REMEMBER You need to set up SSH keys yourself for your server if you use private repositories.
Installation
mkdir deploy
cd deploy
npm init -y
npm i --save @fulminate/deploy
Usage
import { deploy, server } from '@fulminate/deploy';
deploy;
console.log(`Server running on port ${server.appOptions.port}`);
When you run this script, you will get an Express application running.
Setting Up
Create a .fulminate
directory in the root of your project and inside of it, provide the deployment options in an app.yml
file:
bcrypt:
enabled: false
slackOptions:
enabled: false
channel: 'general'
apiKey: 'key'
domain: 'example.com'
port: 3000
viewOptions:
enabled: false
deployOptions:
enabled: true
route: /deploy/api/v1/hook
projects:
main:
branch: master
repository: git@github.com:fulminate-js/bootstrap.git
projectDir: ~/Documents/testing
buildFolderName: build
beforeCopyScripts:
- npm i
- npm run build
filesToCopy:
- location: ./app.yml
savingPath: $PROJECT_DIR/.fulminate/
scripts:
- npm i --only=production
- pm2 reload main
Adding files to copy
In the root folder of the deployer, let's create the file listed in the filesToCopy
property of our app.yml
.
port: 3001
Integration
Open settings of your project, create a hook to the route from the ./.fulminate/app.yml
and set it to be executed on pipeline. Fulminate Deploy will only work on successful build (will be an option in a later release).
Example hook URL: https://test.com/deploy/api/v1/hook/main
Workflow
- You push code to VCS
- Pipeline is executed and sends a hook to Fulminate Deploy
- If the pipeline was successful:
- FD creates a backup copy of the current state of your project
- FD clones the repository to a temporary directory
- FD executes all the
beforeCopyScripts
- FD copies the contents of the temporary directory to your project directory
- FD executes all the
scripts
- FD writes a log to
./history.json
file