File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : CI/CD – Deploy Backend
2+
3+ on :
4+ push :
5+ branches :
6+ - main
7+
8+ jobs :
9+ deploy :
10+ runs-on : ubuntu-latest
11+
12+ steps :
13+ - name : Checkout code
14+ uses : actions/checkout@v4
15+
16+ - name : Setup SSH
17+ run : |
18+ mkdir -p ~/.ssh
19+ echo "${{ secrets.EC2_SSH_KEY }}" > ~/.ssh/id_rsa
20+ chmod 600 ~/.ssh/id_rsa
21+ ssh-keyscan -H ${{ secrets.EC2_HOST }} >> ~/.ssh/known_hosts
22+
23+ - name : Deploy to EC2
24+ run : |
25+ ssh -i ~/.ssh/id_rsa ${{ secrets.EC2_USER }}@${{ secrets.EC2_HOST }} << 'EOF'
26+ cd mysocialcode
27+ git pull origin main
28+ cd backend
29+ pnpm install
30+ pm2 restart all
31+ EOF
Original file line number Diff line number Diff line change @@ -13,11 +13,12 @@ if (!process.env.PORT) {
1313 logger . info ( 'database connected success fully' ) ;
1414 } catch ( error ) {
1515 logger . error ( { err : error } , 'error connecting the database' ) ;
16-
1716 process . exit ( 1 ) ;
1817 }
1918} ) ( ) ;
2019
2120app . listen ( process . env . PORT , ( ) => {
2221 logger . info ( 'server started dont need worry' ) ;
2322} ) ;
23+
24+
You can’t perform that action at this time.
0 commit comments