Skip to content

Commit 74299d0

Browse files
authored
Merge pull request #35 from hacknyu/sarthak/auto-deploy
Add GitHub action to automate deployments
2 parents 7b45546 + 636e277 commit 74299d0

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

.github/workflows/deploy.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Deploy to DigitalOcean
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 repo
14+
uses: actions/checkout@v3
15+
16+
- name: Setup Node.js
17+
uses: actions/setup-node@v3
18+
with:
19+
node-version: '18'
20+
21+
- name: Install dependencies
22+
run: npm install
23+
24+
- name: Build the app
25+
run: npm run build
26+
27+
- name: Copy files to server
28+
uses: appleboy/[email protected]
29+
with:
30+
host: ${{ secrets.DO_HOST }}
31+
username: ${{ secrets.DO_USER }}
32+
key: ${{ secrets.DO_SSH_KEY }}
33+
source: "dist"
34+
target: "${{ secrets.DEPLOY_TARGET_PATH }}temp-build"
35+
36+
- name: Rename and swap build folder via SSH
37+
uses: appleboy/[email protected]
38+
with:
39+
host: ${{ secrets.DO_HOST }}
40+
username: ${{ secrets.DO_USER }}
41+
key: ${{ secrets.DO_SSH_KEY }}
42+
script: |
43+
cd ${{ secrets.DEPLOY_TARGET_PATH }}
44+
rm -rf 2025
45+
mv temp-build/dist 2025
46+
rm -rf temp-build

0 commit comments

Comments
 (0)