Replace Hostinger GIT integration with SSH direct deploy
Hostinger GIT integration has a persistent backend bug that prevents using the correct plugin directory name. This replaces it with SSH-based deployment: - Sync deploy branch with clean plugin runtime files - SSH into Hostinger and git pull deploy branch directly - Purge LiteSpeed cache after successful deploy
This commit is contained in:
54
.github/workflows/deploy.yml
vendored
54
.github/workflows/deploy.yml
vendored
@@ -13,17 +13,14 @@ concurrency:
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
# ── Run tests first ──────────────────────────────────────────────
|
||||
# -- Run tests first --
|
||||
test:
|
||||
name: Pre-deploy tests
|
||||
uses: ./.github/workflows/ci.yml
|
||||
|
||||
# ── 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:
|
||||
name: Update deploy branch
|
||||
# -- Push clean plugin files to the deploy branch --
|
||||
sync-deploy-branch:
|
||||
name: Sync deploy branch
|
||||
runs-on: ubuntu-latest
|
||||
needs: test
|
||||
environment: production
|
||||
@@ -67,15 +64,46 @@ jobs:
|
||||
git commit -m "Deploy ${GITHUB_SHA::7} from main"
|
||||
fi
|
||||
|
||||
# Normal push (fast-forward compatible with Hostinger's git pull).
|
||||
# Normal push (fast-forward).
|
||||
git push origin deploy
|
||||
|
||||
# -- Deploy to Hostinger via SSH --
|
||||
# SSH into Hostinger and git pull the deploy branch directly into
|
||||
# the correct plugin directory (peptide-news-plugin).
|
||||
deploy:
|
||||
name: Deploy to Hostinger
|
||||
runs-on: ubuntu-latest
|
||||
needs: sync-deploy-branch
|
||||
environment: production
|
||||
steps:
|
||||
- name: Pull deploy branch on Hostinger
|
||||
uses: appleboy/ssh-action@v1
|
||||
with:
|
||||
host: ${{ secrets.SSH_HOST }}
|
||||
username: ${{ secrets.SSH_USERNAME }}
|
||||
key: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||
port: ${{ secrets.SSH_PORT }}
|
||||
script: |
|
||||
PLUGIN_DIR="$HOME/domains/peptiderepo.com/public_html/wp-content/plugins/peptide-news-plugin"
|
||||
REPO_URL="git@github.com:peptiderepo/peptide-news-plugin.git"
|
||||
|
||||
if [ -d "$PLUGIN_DIR/.git" ]; then
|
||||
# Existing clone -- just pull latest.
|
||||
cd "$PLUGIN_DIR"
|
||||
git fetch origin deploy
|
||||
git reset --hard origin/deploy
|
||||
else
|
||||
# First deploy -- clone the deploy branch.
|
||||
rm -rf "$PLUGIN_DIR"
|
||||
git clone -b deploy "$REPO_URL" "$PLUGIN_DIR"
|
||||
fi
|
||||
|
||||
echo "Deployed to $PLUGIN_DIR"
|
||||
ls -la "$PLUGIN_DIR"
|
||||
|
||||
- name: Purge LiteSpeed Cache
|
||||
if: success()
|
||||
run: |
|
||||
# Give Hostinger a moment to pull the new code.
|
||||
sleep 10
|
||||
|
||||
# Trigger a cache purge via the WordPress REST API.
|
||||
if [ -n "${{ secrets.WP_APP_PASSWORD }}" ]; then
|
||||
curl -s -X POST \
|
||||
@@ -83,7 +111,7 @@ jobs:
|
||||
"${{ secrets.WP_SITE_URL }}/wp-json/peptide-news/v1/cache-purge" \
|
||||
--max-time 15 || echo "Cache purge skipped (endpoint not available)"
|
||||
else
|
||||
echo "No WP_APP_PASSWORD set — skipping remote cache purge."
|
||||
echo "No WP_APP_PASSWORD set -- skipping remote cache purge."
|
||||
fi
|
||||
|
||||
- name: Deploy summary
|
||||
@@ -92,5 +120,5 @@ jobs:
|
||||
echo "" >> $GITHUB_STEP_SUMMARY
|
||||
echo "- **Branch:** \`${{ github.ref_name }}\`" >> $GITHUB_STEP_SUMMARY
|
||||
echo "- **Commit:** \`${GITHUB_SHA::7}\`" >> $GITHUB_STEP_SUMMARY
|
||||
echo "- **Method:** Hostinger GIT auto-deploy (deploy branch)" >> $GITHUB_STEP_SUMMARY
|
||||
echo "- **Method:** SSH direct deploy (git pull on Hostinger)" >> $GITHUB_STEP_SUMMARY
|
||||
echo "- **Deployed to:** ${{ secrets.WP_SITE_URL || 'peptiderepo.com' }}" >> $GITHUB_STEP_SUMMARY
|
||||
|
||||
Reference in New Issue
Block a user