106 lines
4.0 KiB
YAML
Executable File
106 lines
4.0 KiB
YAML
Executable File
name: Deploy PRAutoBlogger to Hostinger
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
|
|
concurrency:
|
|
group: deploy-prautoblogger-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
validate:
|
|
name: PHP Lint Gate
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- 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-staging:
|
|
name: Deploy to Staging
|
|
needs: validate
|
|
runs-on: ubuntu-latest
|
|
environment: staging
|
|
steps:
|
|
- 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 → staging
|
|
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/staging/wp-content/plugins/prautoblogger/
|
|
- name: Staging health check
|
|
run: |
|
|
sleep 5
|
|
STATUS=$(curl -s -o /dev/null -w "%{http_code}" https://staging.peptiderepo.com/ || echo "000")
|
|
echo "Staging responded: HTTP $STATUS"
|
|
[ "$STATUS" = "000" ] && echo "Warning: staging DNS may still be propagating" || true
|
|
- name: Cleanup
|
|
if: always()
|
|
run: rm -f ~/.ssh/deploy_key
|
|
|
|
deploy-production:
|
|
name: Deploy to Production
|
|
needs: [validate, deploy-staging]
|
|
runs-on: ubuntu-latest
|
|
environment: production
|
|
steps:
|
|
- 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 → production
|
|
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: Production 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 "Production healthy (HTTP $STATUS)"
|
|
- name: Cleanup
|
|
if: always()
|
|
run: rm -f ~/.ssh/deploy_key
|