-
Notifications
You must be signed in to change notification settings - Fork 1
88 lines (74 loc) · 2.68 KB
/
Copy pathdeploy.yml
File metadata and controls
88 lines (74 loc) · 2.68 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
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
82
83
84
85
86
87
88
name: 🚀 Publish Website to Production Environment
on:
push:
branches:
- main
jobs:
web-deploy:
name: 🚀 Deploy Website on Push
runs-on: ubuntu-latest
environment:
name: production
steps:
# deploy server config
- name: 🔐 Install SSH Key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_PRIVATE_KEY }}
known_hosts: github.com
- name: 📂 Pull Latest Code on Server
uses: appleboy/ssh-action@v1.0.3
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USERNAME }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
port: ${{ secrets.SERVER_PORT }}
script: |
# Menjalankan ssh-agent untuk mengelola kunci SSH
# source: https://github.com/appleboy/ssh-action/issues/232#issuecomment-1849260489
eval `ssh-agent -s`
ssh-add ~/.ssh/papuanthought
# Pindah ke direktori proyek
cd /var/www/
# Clone repositori privat
if [ ! -d "papuanthought" ]; then
git clone git@github.com:papuaopensource/papuanthought.git papuanthought
else
cd papuanthought
# Fetch latest changes
git fetch origin master
# Reset local changes and ensure latest code is applied
git reset --hard origin/master
fi
- name: 📦 Install Dependencies and Build Assets
uses: appleboy/ssh-action@v1.0.3
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USERNAME }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
port: ${{ secrets.SERVER_PORT }}
script: |
# Install dependencies and build assets
cd /var/www/papuanthought
# Load nvm and set up Node.js environment
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
# Ensure uv is available in PATH
export PATH="$HOME/.local/bin:$PATH"
# Install dependencies
uv sync
uv run manage.py tailwind install
# Build Tailwind CSS
uv run manage.py tailwind build
# Collect static files
uv run manage.py collectstatic --noinput
- name: 🧹 Restart Supervisor services for papuanthought
uses: appleboy/ssh-action@v1.0.3
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USERNAME }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
port: ${{ secrets.SERVER_PORT }}
script: |
echo "Restart Supervisor services for papuanthought"
sudo supervisorctl restart papuanthought