Skip to content

Commit 92c186f

Browse files
committed
feat: added ci/cd yml file
1 parent e0dd7a8 commit 92c186f

4 files changed

Lines changed: 5091 additions & 1774 deletions

File tree

.github/workflows/ci.yml

Whitespace-only changes.

.github/workflows/cicd.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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

backend/src/server.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff 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

2120
app.listen(process.env.PORT, () => {
2221
logger.info('server started dont need worry');
2322
});
23+
24+

0 commit comments

Comments
 (0)