ci: inline deploy key setup for rsync
Some checks failed
deploy / build-and-deploy (push) Failing after 11s

This commit is contained in:
voson
2026-02-03 11:29:55 +08:00
parent f24ddcbedb
commit cdb53bde62

View File

@@ -30,11 +30,20 @@ jobs:
PUBLIC_NEWSLETTER_DESCRIPTION: ${{ secrets.PUBLIC_NEWSLETTER_DESCRIPTION }}
run: npm run build
- name: Start SSH agent
- name: Write deploy key
if: ${{ secrets.DEPLOY_SSH_KEY != '' }}
uses: webfactory/ssh-agent@v0.9.0
with:
ssh-private-key: ${{ secrets.DEPLOY_SSH_KEY }}
env:
DEPLOY_SSH_KEY: ${{ secrets.DEPLOY_SSH_KEY }}
run: |
mkdir -p ~/.ssh
python3 - <<'PY'
import os
from pathlib import Path
key = os.environ['DEPLOY_SSH_KEY']
p = Path.home() / '.ssh' / 'deploy_key'
p.write_text(key, encoding='utf-8')
PY
chmod 600 ~/.ssh/deploy_key
- name: Add known_hosts
if: ${{ secrets.DEPLOY_SSH_KEY != '' }}
@@ -45,4 +54,4 @@ jobs:
- name: Deploy via rsync
if: ${{ secrets.DEPLOY_SSH_KEY != '' }}
run: |
rsync -az --delete -e "ssh -p ${{ secrets.DEPLOY_SSH_PORT }}" dist/ "${{ secrets.DEPLOY_SSH_USER }}@${{ secrets.DEPLOY_SSH_HOST }}:${{ secrets.DEPLOY_PATH }}/"
rsync -az --delete -e "ssh -i ~/.ssh/deploy_key -p ${{ secrets.DEPLOY_SSH_PORT }}" dist/ "${{ secrets.DEPLOY_SSH_USER }}@${{ secrets.DEPLOY_SSH_HOST }}:${{ secrets.DEPLOY_PATH }}/"