99 lines
3.2 KiB
YAML
Executable File
99 lines
3.2 KiB
YAML
Executable File
name: Deploy PRAutoBlogger to Hostinger
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
|
|
jobs:
|
|
validate:
|
|
name: Validate Code Quality
|
|
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'
|
|
tools: composer, phpcs
|
|
coverage: none
|
|
|
|
- name: PHP Lint Check
|
|
run: |
|
|
find . -name "*.php" -not -path "./vendor/*" -not -path "./node_modules/*" -exec php -l {} \; | (grep -v "No syntax errors" || true) | head -20
|
|
test ${PIPESTATUS[0]} -eq 0
|
|
|
|
- name: Install Composer dependencies
|
|
run: composer install --no-interaction --prefer-dist
|
|
|
|
- name: Install WordPress Coding Standards
|
|
run: |
|
|
composer global require "wp-coding-standards/wpcs:^3.0" "phpcsstandards/phpcsutils:^1.0" --no-interaction
|
|
phpcs --config-set installed_paths "$(composer global config home)/vendor/wp-coding-standards/wpcs"
|
|
|
|
- name: Run PHPCS (WordPress standards)
|
|
run: |
|
|
phpcs --standard=WordPress-Core \
|
|
--extensions=php \
|
|
--ignore=vendor/*,tests/*,node_modules/* \
|
|
--warning-severity=0 \
|
|
--report=summary \
|
|
includes/ prautoblogger.php uninstall.php || true
|
|
|
|
- name: Run PHPUnit
|
|
run: vendor/bin/phpunit --testdox
|
|
|
|
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 && 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" ]; then
|
|
echo "WARNING: Site returned HTTP $STATUS after deploy"
|
|
exit 1
|
|
fi
|
|
echo "Site is healthy (HTTP 200)"
|
|
|
|
- name: Cleanup
|
|
if: always()
|
|
run: rm -f ~/.ssh/deploy_key
|