-
Notifications
You must be signed in to change notification settings - Fork 0
51 lines (41 loc) · 1.26 KB
/
deploy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
name: Build and Deploy
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 21
- name: Install dependencies
run: npm install --legacy-peer-deps
- name: Create .env file
run: |
echo "STRAPI_TOKEN=${{ secrets.STRAPI_TOKEN }}" >> .env
echo "STRAPI_HOST=${{ secrets.STRAPI_HOST }}" >> .env
- name: Build Next.js app
run: npm run build
- name: Deploy to Server using SCP
uses: appleboy/scp-action@master
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USER }}
password: ${{ secrets.SERVER_PASSWORD }}
port: ${{ secrets.SERVER_PORT }}
source: "./"
target: "/srv/www/html/"
- name: Run remote commands
run: |
ssh -i ~/.ssh/id_ed25519 ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_HOST }} << 'EOF'
export STRAPI_TOKEN=${{ secrets.STRAPI_TOKEN }}
export STRAPI_HOST=${{ secrets.STRAPI_HOST }}
cd /srv/www/html
npm install
pm2 restart nextjs-app || pm2 start npm --name "nextjs-app" -- start
EOF