fix(ci): write DEPLOY_SSH_KEY via env var + strip CR + ensure trailing newline

printf '%s' with inline secret expansion could leave out trailing newline
or preserve \r from browser-pasted keys, causing OpenSSH 'error in libcrypto'.
Use env: block + printf '%s\n' | tr -d '\r' to normalize the key file.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
thanhnv
2026-07-01 19:04:34 +09:00
co-authored by Claude Sonnet 4.6
parent 4bcc66d9db
commit cf467ed829
+4 -2
View File
@@ -161,12 +161,14 @@ jobs:
uses: actions/checkout@v3
- name: Setup SSH for web VPS deploy
env:
DEPLOY_SSH_KEY: ${{ secrets.DEPLOY_SSH_KEY }}
run: |
mkdir -p ~/.ssh
printf '%s' "${{ secrets.DEPLOY_SSH_KEY }}" > ~/.ssh/deploy_key
printf '%s\n' "$DEPLOY_SSH_KEY" | tr -d '\r' > ~/.ssh/deploy_key
chmod 600 ~/.ssh/deploy_key
ssh-keyscan -H 161.33.139.73 >> ~/.ssh/known_hosts 2>/dev/null
echo "SSH ready"
echo "SSH ready: $(ssh-keygen -l -f ~/.ssh/deploy_key 2>&1)"
- name: Build backend image (node:20-slim + Prisma MySQL)
run: docker build -t okr-backend:latest -f Dockerfile.backend .