This bot uses Slack bot token and docomo token
If you got their tokens, you can use them to write to .env file.
SLACK_API_TOKEN=your_slack_token
DOCOMO_API_TOKEN=your_docomo_tokennode index.jsAt first, create a deployment user.
sudo adduser deploy
sudo su - deploy
ssh-keygen -t rsa -b 4096
chmod 600 id_rsa
cat id_rsa.pub >> authorized_keys
chmod 600 authorized_keys
exitNext, you create a node environment.
sudo apt-get update
sudo apt-get install git
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y nodejs
sudo npm install pm2 -gYou have to initialize the server once for pm2. To do so, you should setup node environment to another machine and be able to connect to it via ssh using the key created earlier.
Note: In general, you can connect from development machine without problems, but if you develop on windows, you may not be able to connect properly via pm2, even if you use linux subsystem.
# copy private key created before to '~/.ssh/server'
chmod 600 serverHost <<SERVER_IP>>
User deploy
IdentityFile ~/.ssh/server
git clone https://github.com/kentork/sogy.git
cd sogy
pm2 deploy production setup
# --> Deploying to production environment
# --> on host <<SERVER_IP>>
# ○ hook pre-setup
# ○ running setup
# ○ cloning https://github.com/kentork/sogy.git
# ...Once setup is done, you can deploy sources when ci runs tasks.
First, you register a ssh private key to SSH Permissions on project.
Next, you need to tell the server hostname via environment variables.
You can do it to set SERVER_HOST:<<SERVER_IP>> to Environment Variables on project.
The rest is only to add a deployment code to circle.yml.
...
dependencies:
pre:
npm install -g pm2
...
deployment:
production:
branch: master
commands:
- pm2 deploy ecosystem.config.js production