Skip to content

Commit

Permalink
Adding workflow to deploy to DigitalOcean
Browse files Browse the repository at this point in the history
  • Loading branch information
Rishabh-malhotraa committed Apr 28, 2024
1 parent 06ecee1 commit adae3c5
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 4 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/digital-ocean-prod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: CI/CD Digital Ocean PROD

on:
push:
branches: [deploy]

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 Client
run: cd client && npm install --force && npm run build

- name: Install and Build Server
run: cd server && npm install && 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/dist' # 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: |
rm -rf ~/caucus
git clone https://github.com/Rishabh-malhotraa/caucus.git
mv ~/server/dist ~/caucus/server/
cd ~/caucus/server && npm install && cd ~/ && rm -rf ./server
pm2 stop caucus-server
pm2 start ~/env/ecosystem.config.js --env production
echo 'Deployment successful to digital ocean'
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"scripts": {
"format": "prettier --write \"src/**/*.ts\" \"src/**/*.tsx\"",
"lint": "eslint src/**/*.ts src/**/*.tsx",
"install-client": "cd client && npm install",
"install-client": "cd client && npm install --force",
"install-server": "cd server && npm install",
"install-modules": "npm install && npm run install-client && npm run install-server",
"client": "cd client && npm run start",
Expand Down
4 changes: 2 additions & 2 deletions server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
"main": "build/index.js",
"proxy": "https://caucus.netlify.app/",
"scripts": {
"build-ts": "tsc",
"build": "tsc",
"postinstall": "npm run build-ts",
"start": "npm run serve",
"serve": "node build/index.js",
"serve": "node dist/index.js",
"dev": "nodemon --exec ts-node src/index.ts",
"format": "prettier --write \"src/**/*.ts\""
},
Expand Down
2 changes: 1 addition & 1 deletion server/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
// "sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
"outDir": "./build" /* Redirect output structure to the directory. */,
"outDir": "./dist" /* Redirect output structure to the directory. */,
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "composite": true, /* Enable project compilation */
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
Expand Down

0 comments on commit adae3c5

Please sign in to comment.