fix: switch to rsync deploy for private repo

This commit is contained in:
peptiderepo
2026-04-08 09:35:44 +07:00
parent 9642066846
commit 878e360c96

View File

@@ -13,46 +13,34 @@ jobs:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Deploy via SSH - name: Setup SSH key
uses: appleboy/ssh-action@v1 run: |
with: mkdir -p ~/.ssh
host: ${{ secrets.SSH_HOST }} echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/deploy_key
username: ${{ secrets.SSH_USERNAME }} chmod 600 ~/.ssh/deploy_key
key: ${{ secrets.SSH_PRIVATE_KEY }} ssh-keyscan -p ${{ secrets.SSH_PORT }} ${{ secrets.SSH_HOST }} >> ~/.ssh/known_hosts 2>/dev/null
port: ${{ secrets.SSH_PORT }}
script: |
THEME_DIR="/home/${{ secrets.SSH_USERNAME }}/domains/peptiderepo.com/public_html/wp-content/themes/peptide-starter"
REPO_URL="https://github.com/peptiderepo/peptide-starter-theme.git"
# If this is the first deploy, clone the repo - name: Deploy via rsync
if [ ! -d "$THEME_DIR/.git" ]; then run: |
echo "First deploy — cloning repo..." rsync -avz --delete \
rm -rf "$THEME_DIR" --exclude='.git' \
git clone "$REPO_URL" "$THEME_DIR" --exclude='.github' \
else -e "ssh -i ~/.ssh/deploy_key -p ${{ secrets.SSH_PORT }} -o StrictHostKeyChecking=no" \
echo "Pulling latest changes..." ./ ${{ secrets.SSH_USERNAME }}@${{ secrets.SSH_HOST }}:/home/${{ secrets.SSH_USERNAME }}/domains/peptiderepo.com/public_html/wp-content/themes/peptide-starter/
cd "$THEME_DIR"
git fetch origin main
git reset --hard origin/main
fi
echo "Theme deployed successfully."
- name: Purge LiteSpeed Cache - name: Purge LiteSpeed Cache
uses: appleboy/ssh-action@v1 run: |
with: ssh -i ~/.ssh/deploy_key -p ${{ secrets.SSH_PORT }} -o StrictHostKeyChecking=no \
host: ${{ secrets.SSH_HOST }} ${{ secrets.SSH_USERNAME }}@${{ secrets.SSH_HOST }} << 'ENDSSH'
username: ${{ secrets.SSH_USERNAME }} CACHE_DIR="/home/${{ secrets.SSH_USERNAME }}/domains/peptiderepo.com/public_html/wp-content/litespeed"
key: ${{ secrets.SSH_PRIVATE_KEY }}
port: ${{ secrets.SSH_PORT }}
script: |
# Purge LiteSpeed cache so visitors see the update immediately
CACHE_DIR="/home/${{ secrets.SSH_USERNAME }}/domains/peptiderepo.com/public_html/wp-content/litespeed/cssjs"
if [ -d "$CACHE_DIR" ]; then if [ -d "$CACHE_DIR" ]; then
rm -rf "$CACHE_DIR"/* rm -rf "$CACHE_DIR"/*
echo "LiteSpeed CSS/JS cache purged." echo "LiteSpeed cache purged."
fi fi
# Touch a file to signal LiteSpeed to rebuild
touch "/home/${{ secrets.SSH_USERNAME }}/domains/peptiderepo.com/public_html/.lscache_purge" 2>/dev/null || true touch "/home/${{ secrets.SSH_USERNAME }}/domains/peptiderepo.com/public_html/.lscache_purge" 2>/dev/null || true
echo "Cache purge signal sent." echo "Cache purge signal sent."
ENDSSH
- name: Cleanup
if: always()
run: rm -f ~/.ssh/deploy_key