-
Notifications
You must be signed in to change notification settings - Fork 0
46 lines (39 loc) · 1.21 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
name: deploy
on:
push:
branches:
- master
jobs:
build-and-deploy:
name: Build and deploy
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install NPM dependencies
run: npm install
- name: Build using NPM
run: npm run build
- name: Setup SSH
env:
SSH_KEY_PUBLIC: ${{ secrets.SSH_KEY_PUBLIC }}
SSH_KEY_PRIVATE: ${{ secrets.SSH_KEY_PRIVATE }}
SSH_KNOWN_HOSTS: ${{ secrets.SSH_KNOWN_HOSTS }}
run: |
cd
mkdir -m 700 .ssh
cd .ssh
echo "$SSH_KEY_PUBLIC" > id_rsa.pub
chmod 644 id_rsa.pub
echo "$SSH_KEY_PRIVATE" > id_rsa
chmod 600 id_rsa
echo "$SSH_KNOWN_HOSTS" > known_hosts
chmod 600 known_hosts
- name: Upload build to server
env:
SSH_HOST: ${{ secrets.SSH_HOST }}
run: scp -r build/ "ci@${SSH_HOST}:/var/www/www.matbadev.com-${GITHUB_RUN_NUMBER}/"
- name: Activate uploaded build
env:
SSH_HOST: ${{ secrets.SSH_HOST }}
run: ssh -t "ci@${SSH_HOST}" "ln -sfn www.matbadev.com-${GITHUB_RUN_NUMBER} /var/www/www.matbadev.com"