Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit db2e921

Browse files
committedApr 28, 2024
Adding workflow to deploy to DigitalOcean
1 parent 06ecee1 commit db2e921

File tree

3 files changed

+67
-2
lines changed

3 files changed

+67
-2
lines changed
 
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: CI/CD Digital Ocean PROD
2+
3+
on:
4+
push:
5+
branches: [deploy]
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
11+
strategy:
12+
matrix:
13+
node-version: [14.x]
14+
15+
steps:
16+
- name: 'Checkout Repository'
17+
uses: actions/checkout@v2
18+
19+
- name: Use Node.js ${{ matrix.node-version }}
20+
uses: actions/setup-node@v1
21+
with:
22+
node-version: ${{ matrix.node-version }}
23+
24+
- name: Install and Build Client
25+
run: cd client && npm install --force && npm run build
26+
27+
- name: Install and Build Server
28+
run: cd server && npm install && npm run build
29+
30+
- name: Upload to Server Digital Ocean
31+
uses: appleboy/scp-action@master # This is the action
32+
with:
33+
host: ${{secrets.SSH_HOST_PROD}} # IP address of the server you wish to ssh into
34+
key: ${{secrets.SSH_KEY}} # Private or public key of the server
35+
username: ${{ secrets.SSH_USERNAME }} # User of the server you want to ssh into
36+
passphrase: ${{ secrets.SSH_PASSPHRASE }}
37+
source: 'server/dist' # Path to the directory you want to copy
38+
target: '~/' # Path to the directory you want to copy to
39+
40+
- name: Upload to Client Digital Ocean
41+
uses: appleboy/scp-action@master # This is the action
42+
with:
43+
host: ${{secrets.SSH_HOST_PROD}} # IP address of the server you wish to ssh into
44+
key: ${{secrets.SSH_KEY}} # Private or public key of the server
45+
username: ${{ secrets.SSH_USERNAME }} # User of the server you want to ssh into
46+
passphrase: ${{ secrets.SSH_PASSPHRASE }}
47+
source: 'client/dist' # Path to the directory you want to copy
48+
target: '/var/www/html' # Path to the directory you want to copy to
49+
50+
- name: Start Server
51+
uses: appleboy/ssh-action@v0.1.10 # This is the action
52+
with:
53+
host: ${{secrets.SSH_HOST_PROD}} # IP address of the server you wish to ssh into
54+
key: ${{secrets.SSH_KEY}} # Private or public key of the server
55+
username: ${{ secrets.SSH_USERNAME }} # User of the server you want to ssh into
56+
passphrase: ${{ secrets.SSH_PASSPHRASE }}
57+
58+
script: |
59+
rm -rf ~/caucus
60+
git clone https://github.com/Rishabh-malhotraa/caucus.git
61+
mv ~/server/dist ~/caucus/server/
62+
cd ~/caucus/server && npm install && cd ~/ && rm -rf ./server
63+
pm2 stop caucus-server
64+
pm2 start ~/env/ecosystem.config.js --env production
65+
echo 'Deployment successful to digital ocean'

‎package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"scripts": {
1616
"format": "prettier --write \"src/**/*.ts\" \"src/**/*.tsx\"",
1717
"lint": "eslint src/**/*.ts src/**/*.tsx",
18-
"install-client": "cd client && npm install",
18+
"install-client": "cd client && npm install --force",
1919
"install-server": "cd server && npm install",
2020
"install-modules": "npm install && npm run install-client && npm run install-server",
2121
"client": "cd client && npm run start",

‎server/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
1515
// "sourceMap": true, /* Generates corresponding '.map' file. */
1616
// "outFile": "./", /* Concatenate and emit output to single file. */
17-
"outDir": "./build" /* Redirect output structure to the directory. */,
17+
"outDir": "./dist" /* Redirect output structure to the directory. */,
1818
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
1919
// "composite": true, /* Enable project compilation */
2020
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */

0 commit comments

Comments
 (0)
Please sign in to comment.