-
Notifications
You must be signed in to change notification settings - Fork 0
55 lines (46 loc) · 1.67 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
55
name: Auto Deploy
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
# Step 1: Check out the repository
- name: Checkout code
uses: actions/checkout@v3
# Step 2: Set up SSH
- name: Setup SSH
run: |
mkdir -p ~/.ssh
echo "$SSH_PRIVATE_KEY" | base64 --decode > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
ssh-keyscan -t rsa $SSH_HOSTNAME >> ~/.ssh/known_hosts
echo -e "Host $SSH_VM_NAME\n HostName $SSH_HOSTNAME\n User $SSH_USER\n IdentityFile ~/.ssh/id_ed25519" > ~/.ssh/config
chmod 600 ~/.ssh/config
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
SSH_HOSTNAME: ${{ secrets.SSH_HOSTNAME }}
SSH_USER: ${{ secrets.SSH_USER }}
SSH_VM_NAME: ${{ secrets.SSH_VM_NAME }}
- name: Test SSH Connection
run: ssh $SSH_VM_NAME "echo SSH connection successful!"
env:
SSH_VM_NAME: ${{ secrets.SSH_VM_NAME}}
- name: Execute deploy commands via SSH
run: |
ssh $SSH_VM_NAME '
cd /home/feriado/proximo-feriado
sudo chown -R $SSH_USER:$SSH_USER .
sudo chmod -R 777 .
git pull -f
rm -rf node_modules
mkdir node_modules
/home/debian/.bun/bin/bun install
/home/debian/.bun/bin/bun astro build
pm2 restart proximo-feriado || pm2 start --name proximo-feriado /dist/server/entry.mjs -- start
'
env:
SSH_VM_NAME: ${{ secrets.SSH_VM_NAME}}
SSH_HOSTNAME: ${{ secrets.SSH_HOSTNAME }}
SSH_USER: ${{ secrets.SSH_USER }}