-
Notifications
You must be signed in to change notification settings - Fork 0
83 lines (72 loc) · 2.77 KB
/
Copy pathdeploy-php.yml
File metadata and controls
83 lines (72 loc) · 2.77 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
name: Deploy to ThePlayground
on:
push:
branches: [ "master" ]
workflow_dispatch: # Manual deploy trigger
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Set up PHP 8.3
uses: shivammathur/setup-php@v2
with:
php-version: "8.3"
extensions: mbstring, intl, json, pdo, pdo_mysql
- name: Install Composer dependencies
run: composer install --no-interaction --no-dev --optimize-autoloader
- name: PHP lint
run: find ./ -type f -name "*.php" -print0 | xargs -0 -n1 php -l
- name: Run tests
if: ${{ hashFiles('phpunit.xml', 'phpunit.xml.dist') != '' }}
run: vendor/bin/phpunit --colors=never
- name: Prepare build folder
run: |
mkdir -p build
rsync -av --exclude=".git" --exclude=".github" --exclude="build" ./ build/
# -------------------------
# DRY-RUN DEPLOY
# -------------------------
- name: Dry-run deploy via rsync
id: dryrun
run: |
echo "Starting dry-run..."
mkdir -p ~/.ssh
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/deploy_key
chmod 600 ~/.ssh/deploy_key
rsync -avz --delete --dry-run \
--exclude=".well-known" \
--exclude="cgi-bin" \
--exclude=".ftpquota" \
--exclude=".htaccess" \
-e "ssh -p ${{ secrets.SSH_PORT }} -i ~/.ssh/deploy_key -o StrictHostKeyChecking=no" \
build/ ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:/home/cerberus/public_html/theplayground
# Optional: display dry-run output in PR (if PR)
- name: Comment on PR with dry-run output
if: github.event_name == 'pull_request'
uses: marocchino/sticky-pull-request-comment@v2
with:
header: deploy-preview
message: |
**Dry-run deployment summary**
```
${{ steps.dryrun.outputs.stdout }}
```
# -------------------------
# REAL DEPLOY (manual approval recommended)
# -------------------------
- name: Deploy via rsync
if: github.event_name == 'workflow_dispatch'
run: |
echo "Starting real deploy..."
mkdir -p ~/.ssh
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/deploy_key
chmod 600 ~/.ssh/deploy_key
rsync -avz --delete \
--exclude=".well-known" \
--exclude="cgi-bin" \
--exclude=".ftpquota" \
--exclude=".htaccess" \
-e "ssh -p ${{ secrets.SSH_PORT }} -i ~/.ssh/deploy_key -o StrictHostKeyChecking=no" \
build/ ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:/home/cerberus/public_html/theplayground