The file-based cache delete wasn't clearing LiteSpeed's server-level page cache, causing stale pages after deploy. Now uses wp litespeed-purge all via WP-CLI (with file delete as fallback if CLI unavailable). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
90 lines
2.9 KiB
YAML
Executable File
90 lines
2.9 KiB
YAML
Executable File
name: Deploy PRAutoBlogger to Hostinger
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
|
|
jobs:
|
|
validate:
|
|
name: PHP Lint Gate
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup PHP
|
|
uses: shivammathur/setup-php@v2
|
|
with:
|
|
php-version: '8.1'
|
|
coverage: none
|
|
|
|
- name: PHP Lint Check
|
|
run: |
|
|
set -e
|
|
find . -name '*.php' \
|
|
-not -path './vendor/*' \
|
|
-not -path './node_modules/*' \
|
|
-not -path './.git/*' \
|
|
-not -path './.github/*' \
|
|
-print0 | xargs -0 -n1 -P4 php -l > /dev/null
|
|
|
|
deploy:
|
|
needs: validate
|
|
name: Deploy to Production
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup SSH key
|
|
run: |
|
|
mkdir -p ~/.ssh
|
|
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/deploy_key
|
|
chmod 600 ~/.ssh/deploy_key
|
|
ssh-keyscan -p ${{ secrets.SSH_PORT }} ${{ secrets.SSH_HOST }} >> ~/.ssh/known_hosts 2>/dev/null
|
|
|
|
- name: Deploy via rsync
|
|
run: |
|
|
rsync -avz --delete \
|
|
--exclude '.git' \
|
|
--exclude '.github' \
|
|
--exclude 'tests' \
|
|
--exclude 'phpunit.xml.dist' \
|
|
--exclude 'composer.json' \
|
|
--exclude 'composer.lock' \
|
|
--exclude 'vendor' \
|
|
--exclude '.distignore' \
|
|
--exclude 'ARCHITECTURE.md' \
|
|
--exclude 'CONVENTIONS.md' \
|
|
-e "ssh -i ~/.ssh/deploy_key -p ${{ secrets.SSH_PORT }}" \
|
|
./ ${{ secrets.SSH_USERNAME }}@${{ secrets.SSH_HOST }}:~/domains/peptiderepo.com/public_html/wp-content/plugins/prautoblogger/
|
|
|
|
- name: Purge LiteSpeed Cache
|
|
run: |
|
|
ssh -i ~/.ssh/deploy_key -p ${{ secrets.SSH_PORT }} \
|
|
${{ secrets.SSH_USERNAME }}@${{ secrets.SSH_HOST }} \
|
|
"cd ~/domains/peptiderepo.com/public_html && \
|
|
wp litespeed-purge all 2>/dev/null || \
|
|
(find wp-content/litespeed/ -type f -delete 2>/dev/null; touch .lscache_purge 2>/dev/null) || true"
|
|
|
|
- name: Health check
|
|
run: |
|
|
sleep 5
|
|
STATUS=$(curl -s -o /dev/null -w "%{http_code}" https://peptiderepo.com)
|
|
# 200 = normal healthy response.
|
|
# 403 = peptide-starter-theme v1.5.2 CF-peer validator rejecting this
|
|
# GHA-runner direct-to-origin request as non-Cloudflare traffic.
|
|
# That rejection is the validator working — itself a positive
|
|
# liveness signal. Real user traffic via Cloudflare gets 200.
|
|
if [ "$STATUS" != "200" ] && [ "$STATUS" != "403" ]; then
|
|
echo "ERROR: Site returned unexpected HTTP $STATUS after deploy"
|
|
exit 1
|
|
fi
|
|
echo "Site is responsive (HTTP $STATUS)"
|
|
|
|
- name: Cleanup
|
|
if: always()
|
|
run: rm -f ~/.ssh/deploy_key
|