package.json 中的依赖:
"dependencies": {
"my-repo": "git+ssh://github.com/org-name/my-repo.git"
},
GitHub 操作:
name: Test
on: [push, pull_request]
jobs:
test:
name: Test
runs-on: ubuntu-18.04
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: 12
registry-url: 'https://npm.pkg.github.com'
scope: '@org-name'
- uses: webfactory/ssh-agent@v0.4.1
with:
ssh-private-key: ${{ secrets.DEPLOY_KEY }}
- name: Install dependencies
run: yarn
- name: Test
run: yarn test
GitHub Actions 机密中的 DEPLOY_KEY 是私钥,我已在依赖项 repo 中添加了相应的公钥作为部署密钥。
我生成了密钥ssh-keygen -m PEM -t rsa -b 4096 -C "ssh://github.com/org-name/my-repo.git" -f ./deploykey -q -N ""
这是我在 GitHub Actions 输出中看到的失败:
Exit code: 128
Command: git
Arguments: ls-remote --tags --heads ssh://github.com/org-name/my-repo.git
Directory: /home/runner/work/auth-package/auth-package
Output:
Warning: Permanently added the RSA host key for IP address '140.82.112.4' to the list of known hosts.
runner@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
真的对这个失去理智了!