-
-
Notifications
You must be signed in to change notification settings - Fork 276
41 lines (35 loc) · 1.33 KB
/
deploy.yml
File metadata and controls
41 lines (35 loc) · 1.33 KB
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
on:
push:
branches:
- master
name: Deploy test instance
jobs:
deploy:
name: Deploy
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install SSH key
uses: shimataro/ssh-key-action@87a8f067114a8ce263df83e9ed5c849953548bc3
with:
key: ${{ secrets.SSH_KEY }}
known_hosts: ${{ secrets.KNOWN_HOSTS }}
- name: Deploy to server
env:
TARGET_HOST_02: srv-04.emailengine.dev
NODE_ENV: production
SERVICE_NAME: wildduck
id: deploy
run: |
mkdir -p ~/.ssh
chmod 700 ~/.ssh
touch ~/.ssh/known_hosts
chmod 600 ~/.ssh/known_hosts
ssh-keygen -R "$TARGET_HOST_02" -f ~/.ssh/known_hosts || true
ssh-keyscan -H "$TARGET_HOST_02" >> ~/.ssh/known_hosts
echo "$GITHUB_SHA" > commit.txt
npm install --omit=dev
tar czf "/tmp/${SERVICE_NAME}.tar.gz" --exclude .git .
scp "/tmp/${SERVICE_NAME}.tar.gz" "deploy@${TARGET_HOST_02}:"
ssh "deploy@${TARGET_HOST_02}" "/opt/deploy.sh ${SERVICE_NAME}"