首页 文章

权限被拒绝使用travis-CI在GitHub中部署

提问于
浏览
0

我正在研究一个我想在GitHub页面中发布的项目 . 要自动化部署过程,我正在使用Travis CI . 为此,我创建了一个 deploy.sh 文件,其中包含以下代码 .

# build
npm run docs:build

# navigate into the build output directory
cd docs/.vuepress/dist

# if you are deploying to a custom domain
# echo 'www.example.com' > CNAME


git add -A
git commit -m 'deploy'

# if you are deploying to https://<USERNAME>.github.io
# git push -f git@github.com:<USERNAME>/<USERNAME>.github.io.git master

# if you are deploying to https://<USERNAME>.github.io/<REPO>
 git push -f git@github.com:<username>/<repo>.git master:gh-pages

cd -

我在 .travis.yml 文件中添加了这个,如下所示

language: nodejs
node_js:
  - "lts/*"
before_script:
   - npm install
script:
 - bash ./scripts/deploy.sh

现在,当我将代码推送到主服务器时,在travis-ci.org中,它显示构建失败,具有以下输出,

Warning: Permanently added the RSA host key for IP address '192.30.253.113' to the list of known hosts.
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
The command "bash ./scripts/deploy.sh" exited with 128.

我已经跟踪了其他类似错误的其他SO答案,如link,也跟着the way生成并添加ssh密钥到我的GitHub帐户但没有成功 . 如果你能帮助我,我将不胜感激 . 谢谢 .

1 回答

  • 1

    如果你想通过ssh推送,那么travis需要访问你生成的ssh密钥的私有部分 . 您要做的是使用travis cli gem加密私钥,将其添加到您的repo,并在部署阶段再次解密并使用它 . 这是step-by-step

相关问题