-
Notifications
You must be signed in to change notification settings - Fork 0
54 lines (43 loc) · 1.56 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
52
53
54
name: Deploy to EC2
on:
push:
branches:
- main
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Debugging
env:
PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
HOST: ${{ secrets.HOST }}
USERNAME: ${{ secrets.USERNAME }}
run: |
echo "$PRIVATE_KEY" | wc -l # should print a number greater than 1
echo "$HOST" # should print the IP address or DNS name of your EC2 instance
echo "$USERNAME" # should print the username you use to log into your EC2 instance
- name: Deploy to server
run: |
mkdir -p ~/.ssh
echo "$PRIVATE_KEY" | base64 -d > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh -T -o StrictHostKeyChecking=no -i ~/.ssh/id_rsa $USERNAME@$HOST << 'EOF'
# Initialize NVM
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
# Change ownership of directory
sudo chown -R $USERNAME:$USERNAME /home/ubuntu/chainscan
cd /home/ubuntu/chainscan
git pull
nvm install
pnpm install
pnpm run build-webapp-simple
sudo systemctl restart chainscan
EOF
shell: bash
env:
PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
HOST: ${{ secrets.HOST }}
USERNAME: ${{ secrets.USERNAME }}