-
Notifications
You must be signed in to change notification settings - Fork 0
65 lines (55 loc) · 1.68 KB
/
deploy-self-hosted.yml
File metadata and controls
65 lines (55 loc) · 1.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
name: Deploy to Local Ubuntu Server (Self-Hosted)
on:
push:
branches:
- main
- production
workflow_dispatch: # Allow manual trigger
jobs:
deploy:
runs-on: self-hosted
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Check runner user
run: |
echo "Running as user: $(whoami)"
echo "Home directory: $HOME"
echo "Current directory: $(pwd)"
shell: bash
- name: Run deployment script
run: |
echo "Starting deployment..."
cd $GITHUB_WORKSPACE
export GIT_BRANCH="${{ github.ref_name }}"
sudo /var/www/posdic/repo/deployment/scripts/update.sh
shell: bash
- name: Check backend service status
run: |
sleep 3
sudo systemctl status posdic-backend --no-pager
shell: bash
- name: Check nginx status
run: |
sudo systemctl status nginx --no-pager
shell: bash
- name: Get deployment info
run: |
echo "Deployment completed successfully!"
echo "Current commit: $(git rev-parse --short HEAD)"
echo "Backend status:"
curl -f http://localhost:3000/api/health || echo "Health check endpoint not available"
shell: bash
- name: Send deployment notification
if: always()
run: |
if [ ${{ job.status }} == 'success' ]; then
echo "✅ Deployment successful on $(hostname)"
else
echo "❌ Deployment failed on $(hostname)"
fi