我试图让git clone
在私人存储库上使用 Github Action,但我不确定应该如何配置它以使用 SSH 连接到 GitHub。顺便说一句,它是 macOS 运行程序。
此时此刻,actions/checkout
工作正常,但是当我打电话时git clone
直接抛出这个错误。
下面提供了 .yml 文件:
name: Release IOS
on:
push:
branches:
- github-action
jobs:
build:
name: Build IPA and upload to TestFlight
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}
- name: Check Github User
run: |
git --version
git config user.name 'MyUsername'
git config user.email 'MyEmail'
git config user.name
git config user.email
env:
NODE_AUTH_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: 14.17.0
env:
NODE_AUTH_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
- name: Set up SSH
uses: pioug/[email protected] /cdn-cgi/l/email-protection
with:
GH_SSH_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Try copy a private repo
run: git clone https://github.com/MyUsername/MyRepo.git
正如 @torek 指出的,该错误是尝试从您的终端读取凭据,因为它耗尽了其他选项(配置等)
由于您在上一步中设置了 ssh,因此您的意图似乎是使用 ssh,因此您应该将 url 更改为 ssh。
run: git clone [email protected] /cdn-cgi/l/email-protection:MyUsername/MyRepo.git
请注意,还有其他选项。您仍然可以使用 https,但使用 git extraheader cli 选项和 PAT。这其实是我们在操作/结账中做什么 https://github.com/actions/checkout/blob/2541b1294d2704b0964813337f33b291d3f8596b/src/git-auth-helper.ts#L56对于常见情况。
https://www.codegrepper.com/code-examples/shell/How+do+I+clone+a+git+repository+with+extraHeader https://www.codegrepper.com/code-examples/shell/How+do+I+clone+a+git+repository+with+extraHeader
为了完整性起见,来自该网站:
PAT="mypat123"
REPO_URL="https://[email protected] /cdn-cgi/l/email-protection/myorg/myrepo/_git/myrepo/"
AUTH=$(echo -n "x-access-token:$PAT" | openssl base64 | tr -d '\n')
git -c http.$REPO_URL.extraheader="Authorization: Basic $AUTH" clone $REPO_URL --no-checkout --branch master
基本上你让它将你的 PAT 作为 base64 编码的标头传递。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)