【发布时间】:2022-06-28 01:10:41
【问题描述】:
每当我将更改推送到我的主分支时,我想在我的 VPS 上自动部署我的私有存储库。我的 yaml 文件如下所示:
name: push-and-deploy-to-server
on:
push:
branches: [ main ]
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: checkout repo
uses: actions/checkout@v2
- name: ssh and deploy
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
port: 22
script: |
git pull origin main
git status
npm install --only=prod
pm2 restart index.js
这不起作用,我收到以下错误:
err: fatal: could not read Username for 'https://github.com': No such device or address
当 ssh 进入我的服务器并自己克隆 repo 时,它会询问我的用户名和密码(访问令牌)。当我提供它时,它可以工作,但是对于 yaml 文件,它就不行了。
如何克隆和部署私有仓库?顺便说一句,这是一个 nodejs 项目。
【问题讨论】:
-
您是否尝试将 ouath-key 添加为用户名,但未通过?
-
您的
with行提供ssh 身份验证数据。然后你告诉你的 Git 使用 https 而不是 ssh,所以 Git 不使用 ssh,并且 ssh 不使用提供的身份验证数据,并且 libcurl 尝试从不存在的用户,并且由于那里没有用户而失败。要么提供 https 身份验证数据,要么使用 ssh url。
标签: node.js git github-actions