在package.json檔案中,我添加了一個參考我們的公共存盤庫之一的依賴項。中的依賴package.json項如下所示:
"ffprobe-static": "git https://github.com/company-name/repo-name.git",
我可以在npm install本地成功運行并使用此依賴項,但是當我推送此代碼時,我們執行的 GitHub 作業流程npm install失敗并出現以下錯誤:
npm ERR! Warning: Permanently added the RSA host key for IP address 'x.x.x.x' to the list of known hosts.
npm ERR! [email protected]: Permission denied (publickey).
npm ERR! fatal: Could not read from remote repository.
npm ERR!
npm ERR! Please make sure you have the correct access rights
npm ERR! and the repository exists.
我不明白這個錯誤的原因,因為我們參考的存盤庫是公共的,而且當我在本地安裝依賴項時我可以訪問同一個存盤庫。
請注意,運行此代碼的存盤庫是私有存盤庫,但參考的存盤庫是公共的,但在同一組織下。
uj5u.com熱心網友回復:
我可以通過在 YAML 檔案中簽出后添加以下步驟來修復它。此外,persist-credentials在結帳步驟中將選項設定為 false。
steps:
- name: Checkout
uses: actions/checkout@v2
with:
persist-credentials: false
- name: Reconfigure git to use HTTP authentication
run: >
git config --global url."https://github.com/".insteadOf
ssh://[email protected]/
uj5u.com熱心網友回復:
您可以嘗試在 GitHub 作業流程中強制使用 https URL 的配置,至少用于測驗:
- name: Fix URL access
run: echo -e '[url "https://github.com/"]\n insteadOf = "ssh://[email protected]/"' >> ~/.gitconfig
- name: Checkout server
uses: actions/checkout@v2
...
或者(就像在這里,只是為了說明你可以把git config insteadOf命令放在哪里):
on: push
jobs:
check-elm:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Checkout submodules
shell: bash
run: |
# From https://github.com/actions/checkout/issues/116#issuecomment-583221947
git config --global url."https://github.com/".insteadOf
ssh://[email protected]/
git submodule sync --recursive
git -c "http.extraheader=Authorization: basic ${{secrets.GITHUB_ACCESS_TOKEN}}" -c protocol.version=2 submodule update --init --force --recursive --depth=1
- uses: actions/setup-node@v1
with:
node-version: '8.16.0'
- run: npm run test
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/452561.html
上一篇:未能將一些參考資料推送到“https://github.com/<username>/my-history.git”
