-
Notifications
You must be signed in to change notification settings - Fork 0
73 lines (58 loc) · 2.13 KB
/
deploy.yml
File metadata and controls
73 lines (58 loc) · 2.13 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
name: Deploy Plugin to Dev Site
on:
push:
branches:
- dev
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
tools: composer:v2
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '20'
- name: Install PHP Dependencies
run: |
composer clear-cache
composer install --no-dev --optimize-autoloader
- name: Install Node.js Dependencies
run: npm install
- name: Build Assets with Webpack
run: npm run build
- name: Deploy Dev to gishehcinema.ir
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
DEV_SERVER: ${{ secrets.DEV_SERVER }}
DEV_PATH: ${{ secrets.DEV_PATH }}
run: |
echo "$SSH_PRIVATE_KEY" > private_key && chmod 600 private_key
# Debug: Check environment variables
echo "DEV_SERVER: $DEV_SERVER"
echo "DEV_PATH: $DEV_PATH"
# Validate DEV_PATH
if [ -z "$DEV_PATH" ]; then
echo "Error: DEV_PATH is empty or not set"
exit 1
fi
# Test SSH connection
ssh -i private_key -o StrictHostKeyChecking=no root@$DEV_SERVER whoami || { echo "SSH connection failed"; exit 1; }
# Deploy with rsync
rsync -avz -vv --exclude 'private_key' --exclude-from='.github/exclude-list.txt' \
-e "ssh -i private_key -o StrictHostKeyChecking=no" \
./ root@$DEV_SERVER:$DEV_PATH/
# Fix ownership and permissions
ssh -i private_key -o StrictHostKeyChecking=no root@$DEV_SERVER << EOF
echo "Updating ownership to gishehcinema2..."
chown -R gishehcinema2:gishehcinema2 "$DEV_PATH"
chmod -R 755 "$DEV_PATH"
echo "Ownership and permissions updated for $DEV_PATH"
ls -ld "$DEV_PATH"
EOF
rm -f private_key