Rsync over SSH on push to main. Runs CI first, then syncs production files to wp-content/plugins/peptide-reconstitution-calculator/ on Hostinger. Includes LiteSpeed cache purge and health check. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
74 lines
2.5 KiB
YAML
Executable File
74 lines
2.5 KiB
YAML
Executable File
name: Deploy to Hostinger
|
|
|
|
on:
|
|
push:
|
|
branches: [ main ]
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
# Cancel previous deploys if a new push arrives while one is running.
|
|
concurrency:
|
|
group: deploy-peptide-reconstitution-calculator
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
# ── Run CI first ─────────────────────────────────────────────────
|
|
ci:
|
|
name: Pre-deploy CI
|
|
uses: ./.github/workflows/ci.yml
|
|
|
|
# ── Deploy via rsync over SSH ────────────────────────────────────
|
|
deploy:
|
|
needs: ci
|
|
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 'phpcs.xml.dist' \
|
|
--exclude 'ARCHITECTURE.md' \
|
|
--exclude 'CONVENTIONS.md' \
|
|
--exclude 'CHANGELOG.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/peptide-reconstitution-calculator/
|
|
|
|
- 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 && 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)
|
|
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
|