-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding workflow to deploy to DigitalOcean
- Loading branch information
1 parent
06ecee1
commit 59dffc8
Showing
5 changed files
with
106 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
name: CI/CD Digital Ocean PROD | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
|
||
env: | ||
REACT_APP_CLIENT_URL: ${{secrets.REACT_APP_CLIENT_URL}} | ||
REACT_APP_SERVER_URL: ${{secrets.REACT_APP_SERVER_URL}} | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
node-version: [14.x] | ||
|
||
steps: | ||
- name: 'Checkout Repository' | ||
uses: actions/checkout@v2 | ||
|
||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
|
||
- name: Install and Build Server | ||
run: cd server && npm install && npm run build | ||
|
||
- name: Install and Build Client | ||
run: cd client && npm install --force && npm run build | ||
|
||
- name: Upload to Server Digital Ocean | ||
uses: appleboy/scp-action@master # This is the action | ||
with: | ||
host: ${{secrets.SSH_HOST_PROD}} # IP address of the server you wish to ssh into | ||
key: ${{secrets.SSH_KEY}} # Private or public key of the server | ||
username: ${{ secrets.SSH_USERNAME }} # User of the server you want to ssh into | ||
passphrase: ${{ secrets.SSH_PASSPHRASE }} | ||
source: 'server/dist' # Path to the directory you want to copy | ||
target: '~/' # Path to the directory you want to copy to | ||
|
||
- name: Upload to Client Digital Ocean | ||
uses: appleboy/scp-action@master # This is the action | ||
with: | ||
host: ${{secrets.SSH_HOST_PROD}} # IP address of the server you wish to ssh into | ||
key: ${{secrets.SSH_KEY}} # Private or public key of the server | ||
username: ${{ secrets.SSH_USERNAME }} # User of the server you want to ssh into | ||
passphrase: ${{ secrets.SSH_PASSPHRASE }} | ||
source: 'client/build' # Path to the directory you want to copy | ||
target: '/var/www/html' # Path to the directory you want to copy to | ||
|
||
- name: Start Server | ||
uses: appleboy/[email protected] # This is the action | ||
with: | ||
host: ${{secrets.SSH_HOST_PROD}} # IP address of the server you wish to ssh into | ||
key: ${{secrets.SSH_KEY}} # Private or public key of the server | ||
username: ${{ secrets.SSH_USERNAME }} # User of the server you want to ssh into | ||
passphrase: ${{ secrets.SSH_PASSPHRASE }} | ||
|
||
script: | | ||
echo $PATH | ||
export NVM_DIR=~/.nvm | ||
source ~/.nvm/nvm.sh | ||
rm -rf ~/caucus | ||
git clone https://github.com/Rishabh-malhotraa/caucus.git | ||
mv ~/server/dist ~/caucus/server/ | ||
cd ~/caucus/server && npm install --production && cd ~/ && rm -rf ./server | ||
pm2 stop caucus-server caucus-crdt-server | ||
pm2 start ~/env/ecosystem.config.js --env production | ||
echo 'Deployment successful to digital ocean' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// configuration for pm2 | ||
// pm2 start ~/env/ecosystem.config.js --env production | ||
|
||
module.exports = { | ||
apps: [ | ||
{ | ||
name: 'caucus-server', | ||
script: '/root/caucus/server/dist/index.js', | ||
watch: true, | ||
env: { | ||
PROD: '', | ||
CLIENT_URL: '', | ||
SERVER_URL: '', | ||
GOOGLE_KEY_CLIENTID: '', | ||
GOOGLE_KEY_CLIENTSECRET: '', | ||
GITHUB_KEY_CLIENTID: '', | ||
GITHUB_KEY_CLIENTSECRET: '', | ||
COOKIE_KEYS: '', | ||
JDOODLE_CLIENTID: '', | ||
JDOOLDE_CLIENTSECRET: '', | ||
PORT: '', | ||
}, | ||
}, | ||
{ | ||
name: 'caucus-crdt-server', | ||
script: 'npx y-websocket', | ||
watch: true, | ||
} | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters