@@ -3,9 +3,10 @@ name: Deploy to ThePlayground
33on :
44 push :
55 branches : [ "master" ]
6+ workflow_dispatch : # Manual deploy trigger
67
78jobs :
8- deploy :
9+ build-and- deploy :
910 runs-on : ubuntu-latest
1011
1112 steps :
@@ -21,39 +22,62 @@ jobs:
2122 - name : Install Composer dependencies
2223 run : composer install --no-interaction --no-dev --optimize-autoloader
2324
24- # Static lint check
2525 - name : PHP lint
26- run : |
27- find ./ -type f -name "*.php" -print0 | xargs -0 -n1 php -l
26+ run : find ./ -type f -name "*.php" -print0 | xargs -0 -n1 php -l
2827
29- # PHPUnit tests (optional)
3028 - name : Run tests
3129 if : ${{ hashFiles('phpunit.xml', 'phpunit.xml.dist') != '' }}
3230 run : vendor/bin/phpunit --colors=never
3331
34- - name : Prepare build
32+ - name : Prepare build folder
3533 run : |
36- mkdir build
37- rsync -av \
38- --exclude=".git" \
39- --exclude=".github" \
40- --exclude="build" \
41- ./ build/
42-
43- - name : Dry-run deploy to theplayground.ws
44- uses : easingthemes/ssh-deploy@v5.0.0
45- with :
46- SSH_PRIVATE_KEY : ${{ secrets.SSH_PRIVATE_KEY }}
47- REMOTE_HOST : ${{ secrets.SSH_HOST }}
48- REMOTE_USER : ${{ secrets.SSH_USER }}
49- REMOTE_PORT : ${{ secrets.SSH_PORT }}
50- TARGET : " /home/cerberus/public_html/theplayground"
51- SOURCE : " build/"
52- ARGS : " --dry-run --delete --verbose --filter=P .well-known/ --filter=P cgi-bin/ --filter=P .ftpquota --filter=P .htaccess"
53- EXCLUDE : |
54- .well-known
55- cgi-bin
56- .ftpquota
57- .htaccess
34+ mkdir -p build
35+ rsync -av --exclude=".git" --exclude=".github" --exclude="build" ./ build/
36+
37+ # -------------------------
38+ # DRY-RUN DEPLOY
39+ # -------------------------
40+ - name : Dry-run deploy via rsync
41+ id : dryrun
42+ run : |
43+ echo "Starting dry-run..."
44+ mkdir -p ~/.ssh
45+ echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/deploy_key
46+ chmod 600 ~/.ssh/deploy_key
47+ rsync -avz --delete --dry-run \
48+ --exclude=".well-known" \
49+ --exclude="cgi-bin" \
50+ --exclude=".ftpquota" \
51+ --exclude=".htaccess" \
52+ -e "ssh -p ${{ secrets.SSH_PORT }} -i ~/.ssh/deploy_key -o StrictHostKeyChecking=no" \
53+ build/ ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:/home/cerberus/public_html/theplayground
5854
55+ # Optional: display dry-run output in PR (if PR)
56+ - name : Comment on PR with dry-run output
57+ if : github.event_name == 'pull_request'
58+ uses : marocchino/sticky-pull-request-comment@v2
59+ with :
60+ header : deploy-preview
61+ message : |
62+ **Dry-run deployment summary**
63+ ```
64+ ${{ steps.dryrun.outputs.stdout }}
65+ ```
5966
67+ # -------------------------
68+ # REAL DEPLOY (manual approval recommended)
69+ # -------------------------
70+ - name : Deploy via rsync
71+ if : github.event_name == 'workflow_dispatch'
72+ run : |
73+ echo "Starting real deploy..."
74+ mkdir -p ~/.ssh
75+ echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/deploy_key
76+ chmod 600 ~/.ssh/deploy_key
77+ rsync -avz --delete \
78+ --exclude=".well-known" \
79+ --exclude="cgi-bin" \
80+ --exclude=".ftpquota" \
81+ --exclude=".htaccess" \
82+ -e "ssh -p ${{ secrets.SSH_PORT }} -i ~/.ssh/deploy_key -o StrictHostKeyChecking=no" \
83+ build/ ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:/home/cerberus/public_html/theplayground
0 commit comments