fix: switch to rsync deploy for private repo
This commit is contained in:
58
.github/workflows/deploy.yml
vendored
58
.github/workflows/deploy.yml
vendored
@@ -13,46 +13,34 @@ jobs:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Deploy via SSH
|
||||
uses: appleboy/ssh-action@v1
|
||||
with:
|
||||
host: ${{ secrets.SSH_HOST }}
|
||||
username: ${{ secrets.SSH_USERNAME }}
|
||||
key: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||
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"
|
||||
- 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
|
||||
|
||||
# If this is the first deploy, clone the repo
|
||||
if [ ! -d "$THEME_DIR/.git" ]; then
|
||||
echo "First deploy — cloning repo..."
|
||||
rm -rf "$THEME_DIR"
|
||||
git clone "$REPO_URL" "$THEME_DIR"
|
||||
else
|
||||
echo "Pulling latest changes..."
|
||||
cd "$THEME_DIR"
|
||||
git fetch origin main
|
||||
git reset --hard origin/main
|
||||
fi
|
||||
|
||||
echo "Theme deployed successfully."
|
||||
- name: Deploy via rsync
|
||||
run: |
|
||||
rsync -avz --delete \
|
||||
--exclude='.git' \
|
||||
--exclude='.github' \
|
||||
-e "ssh -i ~/.ssh/deploy_key -p ${{ secrets.SSH_PORT }} -o StrictHostKeyChecking=no" \
|
||||
./ ${{ secrets.SSH_USERNAME }}@${{ secrets.SSH_HOST }}:/home/${{ secrets.SSH_USERNAME }}/domains/peptiderepo.com/public_html/wp-content/themes/peptide-starter/
|
||||
|
||||
- name: Purge LiteSpeed Cache
|
||||
uses: appleboy/ssh-action@v1
|
||||
with:
|
||||
host: ${{ secrets.SSH_HOST }}
|
||||
username: ${{ secrets.SSH_USERNAME }}
|
||||
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"
|
||||
run: |
|
||||
ssh -i ~/.ssh/deploy_key -p ${{ secrets.SSH_PORT }} -o StrictHostKeyChecking=no \
|
||||
${{ secrets.SSH_USERNAME }}@${{ secrets.SSH_HOST }} << 'ENDSSH'
|
||||
CACHE_DIR="/home/${{ secrets.SSH_USERNAME }}/domains/peptiderepo.com/public_html/wp-content/litespeed"
|
||||
if [ -d "$CACHE_DIR" ]; then
|
||||
rm -rf "$CACHE_DIR"/*
|
||||
echo "LiteSpeed CSS/JS cache purged."
|
||||
echo "LiteSpeed cache purged."
|
||||
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
|
||||
echo "Cache purge signal sent."
|
||||
ENDSSH
|
||||
|
||||
- name: Cleanup
|
||||
if: always()
|
||||
run: rm -f ~/.ssh/deploy_key
|
||||
Reference in New Issue
Block a user