refactor: switch deploy to Hostinger GIT pull-based strategy
Replace broken SCP/SSH deploy (blocked by Hostinger firewall) with a deploy-branch strategy. After CI passes, GitHub Actions pushes only plugin files to the 'deploy' branch. Hostinger's built-in GIT integration watches this branch via webhook and auto-pulls. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
54
.github/workflows/deploy.yml
vendored
54
.github/workflows/deploy.yml
vendored
@@ -5,7 +5,7 @@ on:
|
|||||||
branches: [ main ]
|
branches: [ main ]
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: write
|
||||||
|
|
||||||
# Cancel previous deploys if a new push arrives while one is running.
|
# Cancel previous deploys if a new push arrives while one is running.
|
||||||
concurrency:
|
concurrency:
|
||||||
@@ -18,31 +18,51 @@ jobs:
|
|||||||
name: Pre-deploy tests
|
name: Pre-deploy tests
|
||||||
uses: ./.github/workflows/ci.yml
|
uses: ./.github/workflows/ci.yml
|
||||||
|
|
||||||
# ── Deploy via SSH/SCP ──────────────────────────────────────────
|
# ── Push clean plugin files to the deploy branch ─────────────────
|
||||||
|
# Hostinger's built-in GIT integration watches the `deploy` branch
|
||||||
|
# and auto-pulls via webhook when it changes. This avoids the
|
||||||
|
# firewall issues with push-based SCP/FTP from GitHub Actions.
|
||||||
deploy:
|
deploy:
|
||||||
name: Deploy to Hostinger
|
name: Update deploy branch
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: test # Only deploy if all CI checks pass
|
needs: test
|
||||||
environment: production
|
environment: production
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Deploy plugin files via SCP
|
|
||||||
uses: appleboy/scp-action@v0.1.7
|
|
||||||
with:
|
with:
|
||||||
host: ${{ secrets.SFTP_HOST }}
|
fetch-depth: 0
|
||||||
username: ${{ secrets.SFTP_USER }}
|
|
||||||
password: ${{ secrets.SFTP_PASS }}
|
- name: Build deploy branch
|
||||||
port: ${{ secrets.SFTP_PORT }}
|
run: |
|
||||||
source: "admin/,includes/,languages/,public/,peptide-news-plugin.php"
|
git config user.name "github-actions[bot]"
|
||||||
target: ${{ secrets.WP_PLUGIN_PATH }}
|
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||||
overwrite: true
|
|
||||||
|
# Create a temporary orphan branch with only plugin files.
|
||||||
|
git checkout --orphan deploy-staging
|
||||||
|
|
||||||
|
# Remove everything from the index.
|
||||||
|
git rm -rf --cached . > /dev/null 2>&1 || true
|
||||||
|
|
||||||
|
# Stage only the plugin runtime files.
|
||||||
|
git add -f \
|
||||||
|
admin/ \
|
||||||
|
includes/ \
|
||||||
|
languages/ \
|
||||||
|
public/ \
|
||||||
|
peptide-news-plugin.php
|
||||||
|
|
||||||
|
git commit -m "Deploy ${GITHUB_SHA::7} from main"
|
||||||
|
|
||||||
|
# Force-push to the deploy branch (Hostinger webhook triggers auto-pull).
|
||||||
|
git push --force origin deploy-staging:deploy
|
||||||
|
|
||||||
- name: Purge LiteSpeed Cache
|
- name: Purge LiteSpeed Cache
|
||||||
if: success()
|
if: success()
|
||||||
run: |
|
run: |
|
||||||
|
# Give Hostinger a moment to pull the new code.
|
||||||
|
sleep 10
|
||||||
|
|
||||||
# Trigger a cache purge via the WordPress REST API.
|
# Trigger a cache purge via the WordPress REST API.
|
||||||
# This requires an Application Password set up in WordPress.
|
|
||||||
if [ -n "${{ secrets.WP_APP_PASSWORD }}" ]; then
|
if [ -n "${{ secrets.WP_APP_PASSWORD }}" ]; then
|
||||||
curl -s -X POST \
|
curl -s -X POST \
|
||||||
-u "${{ secrets.WP_ADMIN_USER }}:${{ secrets.WP_APP_PASSWORD }}" \
|
-u "${{ secrets.WP_ADMIN_USER }}:${{ secrets.WP_APP_PASSWORD }}" \
|
||||||
@@ -50,7 +70,6 @@ jobs:
|
|||||||
--max-time 15 || echo "Cache purge skipped (endpoint not available)"
|
--max-time 15 || echo "Cache purge skipped (endpoint not available)"
|
||||||
else
|
else
|
||||||
echo "No WP_APP_PASSWORD set — skipping remote cache purge."
|
echo "No WP_APP_PASSWORD set — skipping remote cache purge."
|
||||||
echo "Remember to purge LiteSpeed Cache manually after deploy."
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Deploy summary
|
- name: Deploy summary
|
||||||
@@ -58,5 +77,6 @@ jobs:
|
|||||||
echo "## Deployment Complete" >> $GITHUB_STEP_SUMMARY
|
echo "## Deployment Complete" >> $GITHUB_STEP_SUMMARY
|
||||||
echo "" >> $GITHUB_STEP_SUMMARY
|
echo "" >> $GITHUB_STEP_SUMMARY
|
||||||
echo "- **Branch:** \`${{ github.ref_name }}\`" >> $GITHUB_STEP_SUMMARY
|
echo "- **Branch:** \`${{ github.ref_name }}\`" >> $GITHUB_STEP_SUMMARY
|
||||||
echo "- **Commit:** \`${{ github.sha }}\`" >> $GITHUB_STEP_SUMMARY
|
echo "- **Commit:** \`${GITHUB_SHA::7}\`" >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "- **Method:** Hostinger GIT auto-deploy (deploy branch)" >> $GITHUB_STEP_SUMMARY
|
||||||
echo "- **Deployed to:** ${{ secrets.WP_SITE_URL || 'peptiderepo.com' }}" >> $GITHUB_STEP_SUMMARY
|
echo "- **Deployed to:** ${{ secrets.WP_SITE_URL || 'peptiderepo.com' }}" >> $GITHUB_STEP_SUMMARY
|
||||||
|
|||||||
Reference in New Issue
Block a user