Github在windows-2019上检出兄弟私有repo的操作失败,ssh: Could not resolve h



我有一个github动作来构建一个。net Framework 4.8解决方案上的windows-2019 github托管的运行器。主回购依赖于兄弟回购(称为Common.Net),其中包含需要构建的其他项目。使用:

获取同级repo失败
ssh: Could not resolve hostname key-blahblahblah.github.com: Name or service not known
Error: fatal: Could not read from remote repository.

.yaml:

name: cd-build
on:
workflow_dispatch:
push:
branches:
- master
- qa
- dev
jobs:
build:
runs-on: windows-2019
env:
APP_NAME: RemoteSignWorkerDotNet

steps:
- name: Code Checkout
uses: actions/checkout@v3.5.0

- name: Setup to use ssh instead of https
run: git config --global url.git@github.com:.insteadOf https://github.com/
- name: set key in ssh-agent
uses: webfactory/ssh-agent@v0.7.0
with:
ssh-private-key: ${{ secrets.MYORG_COMMONDOTNET_PRIVATE_KEY }}
- name: Code Checkout MyOrg/Common.Net
uses: actions/checkout@v3.5.0
with:
repository: MyOrg/Common.Net
token: ${{ secrets.MYORG_COMMONDOTNET_PRIVATE_KEY }}
path: Common.Net
ref: master

所有的步骤都成功了,除了最后一个名为Code Checkout MyOrg/Common.Net的步骤,它会产生上面提到的错误。

我知道Deploy键是正确的,因为当我将其从runs-on: windows-2019更改为runs-on: ubuntu-latest时,上面的代码检查为Common。Net工作得很好。这似乎是windows的一个问题。我怎样才能在windows上工作?

看起来您正在使用SSH密钥并将其作为PAT应该去的token传递。它应该通过ssh-key配置。

请参考actions/checkout的用法:

# Personal access token (PAT) used to fetch the repository. The PAT is configured
# with the local git config, which enables your scripts to run authenticated git
# commands. The post-job step removes the PAT.
# ...
#
# Default: ${{ github.token }}
token: ''

,

# SSH key used to fetch the repository. The SSH key is configured with the local
# git config, which enables your scripts to run authenticated git commands. The
# post-job step removes the SSH key.
# ...
ssh-key: ''