File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -100,19 +100,23 @@ jobs:
100100 - name : Add server to known hosts
101101 run : |
102102 mkdir -p ~/.ssh
103- ssh-keyscan -H ${{ secrets.SSH_HOST }} >> ~/.ssh/known_hosts
103+ chmod 700 ~/.ssh
104+ ssh-keyscan -H ${{ secrets.SSH_HOST }} 2>/dev/null >> ~/.ssh/known_hosts || echo "Warning: ssh-keyscan failed, will use StrictHostKeyChecking=accept-new"
105+ chmod 644 ~/.ssh/known_hosts
104106
105107 - name : Deploy to ${{ env.ENVIRONMENT }}
106108 run : |
107109 DEPLOY_PATH="${{ env.DEPLOY_PATH }}"
108110 PM2_APP_NAME="${{ env.PM2_APP_NAME }}"
109111 ECOSYSTEM_FILE="${{ env.ECOSYSTEM_FILE }}"
110112
111- # Copy files to server
112- scp -r deploy.tar.gz ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:$DEPLOY_PATH/
113+ # Copy files to server (accept new host keys automatically)
114+ scp -o StrictHostKeyChecking=accept-new -o UserKnownHostsFile=~/.ssh/known_hosts \
115+ -r deploy.tar.gz ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:$DEPLOY_PATH/
113116
114- # SSH into server and deploy
115- ssh ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} "bash -s" << EOF
117+ # SSH into server and deploy (accept new host keys automatically)
118+ ssh -o StrictHostKeyChecking=accept-new -o UserKnownHostsFile=~/.ssh/known_hosts \
119+ ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} "bash -s" << EOF
116120 set -e
117121 cd $DEPLOY_PATH
118122
You can’t perform that action at this time.
0 commit comments