Switch deploy to key-based rsync over SSH

This commit is contained in:
Leon Xu committed 2026-11-29 14:25:19 -08:00
1 parent 371ff680d4
commit 4aa456906d
1 file changed
+18 -14
+18 -14
View File
@@ -24,20 +24,24 @@ jobs:
- name: Install dependencies - name: Install dependencies
run: yarn install --frozen-lockfile run: yarn install --frozen-lockfile
# hexo-deployer-sftp reads credentials from the hexo config, which
# cannot take env vars directly. Generate an override config from
# Gitea Actions secrets instead; it is never committed to the repo.
- name: Write deploy config from secrets
env:
SFTP_HOST: ${{ secrets.SFTP_HOST }}
SFTP_USER: ${{ secrets.SFTP_USER }}
SFTP_PASS: ${{ secrets.SFTP_PASS }}
run: |
printf 'deploy:\n - type: sftp\n host: %s\n port: 22\n user: %s\n pass: %s\n remotePath: /www/wwwroot/leonxu260.dev\n' \
"$SFTP_HOST" "$SFTP_USER" "$SFTP_PASS" > _deploy.yml
- name: Build site - name: Build site
run: hexo generate run: hexo generate
- name: Deploy via SFTP # Deploy over SSH with a key (the server rejects password auth).
run: hexo deploy --config _config.yml,_deploy.yml # The private key never touches the repo -- it lives in the
# DEPLOY_KEY secret. The IP is pinned on purpose: the domain's DNS
# is behind Cloudflare, which does not proxy SSH at all.
- name: Write deploy key from secret
env:
DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }}
run: |
install -d -m 700 "$HOME/.ssh"
printf '%s\n' "$DEPLOY_KEY" > "$HOME/.ssh/deploy_key"
chmod 600 "$HOME/.ssh/deploy_key"
- name: Deploy via rsync over SSH
run: |
command -v rsync >/dev/null || { apt-get update -qq && apt-get install -y -qq rsync; }
rsync -avz --chmod=D755,F644 \
-e "ssh -i $HOME/.ssh/deploy_key -o StrictHostKeyChecking=accept-new" \
public/ root@69.164.253.99:/www/wwwroot/leonxu260.dev/