-
Notifications
You must be signed in to change notification settings - Fork 0
81 lines (69 loc) · 2.71 KB
/
deploy-main-on-prod.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
name: deploy main on production
on:
workflow_run:
workflows: ["merge dev to main"]
types: [completed]
jobs:
deploy:
name: deploy
runs-on: ubuntu-latest
environment:
name: ${{ github.ref_name == 'main' && 'prod' || 'dev' }}
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
steps:
- uses: actions/checkout@v4
- name: Setup .env file
run: |
echo "
MODE=prod
RELEASE=$(git rev-parse --short HEAD)
RELEASE_AT=$(date -u +%Y-%m-%dT%H:%M:%SZ)
PORT=${{ secrets.POSTFOO_HOST_PORT }}
DATABASE_URL=\"${{ secrets.POSTFOO_DB_URL }}\"
SEND_PULSE_API_USER_ID=${{ secrets.POSTFOO_SEND_PULSE_API_USER_ID }}
SEND_PULSE_API_USER_SECRET=${{ secrets.POSTFOO_SEND_PULSE_API_USER_SECRET }}
AUTH_PRIVATE_KEY=\"${{ secrets.POSTFOO_AUTH_PRIVATE_KEY }}\"
AUTH_PUBLIC_KEY=\"${{ secrets.POSTFOO_AUTH_PUBLIC_KEY }}\"
SENTRY_DSN=https://3d033d8a13db28584e868bcbc6963f26@o4508675017474048.ingest.us.sentry.io/4508677112332288
" > .env
cat .env
- name: Add environment variables to Github
run: |
echo "MODE=prod" >> $GITHUB_ENV
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'npm'
- name: Install Node.js dependencies
run: npm ci
- name: Lint
run: npm run lint
- name: Build
run: npm run build
- name: Stop the Server
uses: garygrossgarten/github-action-ssh@release
with:
host: ${{ secrets.POSTFOO_SSH_HOST }}
port: ${{ secrets.POSTFOO_SSH_PORT }}
username: ${{ secrets.POSTFOO_SSH_USERNAME }}
privateKey: ${{ secrets.POSTFOO_SSH_PKEY }}
command: cd /root/spiderman/postfoo-server; pm2 stop spiderman; pm2 delete spiderman; mkdir -p /root/spiderman/postfoo-server
- name: Deploy to DigitalOcean
uses: burnett01/rsync-deployments@7.0.1
with:
switches: -avzr --delete --checksum
remote_path: /root/spiderman/postfoo-server
remote_host: ${{ secrets.POSTFOO_SSH_HOST }}
remote_port: ${{ secrets.POSTFOO_SSH_PORT }}
remote_user: ${{ secrets.POSTFOO_SSH_USERNAME }}
remote_key: ${{ secrets.POSTFOO_SSH_PKEY }}
- name: Start the Server
uses: garygrossgarten/github-action-ssh@release
with:
host: ${{ secrets.POSTFOO_SSH_HOST }}
port: ${{ secrets.POSTFOO_SSH_PORT }}
username: ${{ secrets.POSTFOO_SSH_USERNAME }}
privateKey: ${{ secrets.POSTFOO_SSH_PKEY }}
command: cd /root/spiderman/postfoo-server; pm2 start npm --name "spiderman" -- start