带有私有仓库和私有仓库的 Github 工作流程标签

发布于 2025-01-10 11:06:21 字数 1087 浏览 0 评论 0原文

我在这里问了这个问题,但没有得到回应: https:// github.community/t/private-repo-w-tag-in-workflow/229573

我们有三个私有存储库,其中 package.json 中的标签作为依赖项,一个示例:

"Private-Repo1": "https://:[email protected]/project/Private-Repo.git#v1.0.0",

我们使用 oauth 密钥来访问我们的存储库。我的 PAT 设置为允许检查存储库以及工作流程访问。

当我们运行工作流操作时,该行在 npm ci 处失败,并出现错误:

npm ERR! code 128
npm ERR! An unknown git error occurred
npm ERR! command git --no-replace-objects ls-remote ***github.com/project/Private-Repo.git
npm ERR! remote: Repository not found.
npm ERR! fatal: repository 'https://github.com/project/Private-Repo.git/' not found

本地测试指出我们失败的原因是 git ls-remote 会失败,如果我删除标签,它就会起作用。

我们如何使用 PAT 通过 package.json 从工作流程中的私有存储库中提取特定标签?我能找到的所有内容都是如何访问私人仓库,但不是如何访问私人仓库的标签。

I asked this question here and got no response: https://github.community/t/private-repo-w-tag-in-workflow/229573

We have three private repos with tags in our package.json as dependencies, one example:

"Private-Repo1": "https://<PAT>:[email protected]/project/Private-Repo.git#v1.0.0",

We use oauth keys to access our repos. My PAT is set to allow checking out the repo as well as workflow access.

When we run our Workflow action, it fails at npm ci for this line with an error of:

npm ERR! code 128
npm ERR! An unknown git error occurred
npm ERR! command git --no-replace-objects ls-remote ***github.com/project/Private-Repo.git
npm ERR! remote: Repository not found.
npm ERR! fatal: repository 'https://github.com/project/Private-Repo.git/' not found

Local testing is pointing to the reason that we’re failing is that git ls-remote fails when you point to a private repo with a tag number, if I remove the tag it works.

How can we use a PAT to pull a specific tag from a private repo in our workflow via our package.json? Everything I can find is how to access a private repo, but not how to access a private repo's tag.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

落墨 2025-01-17 11:06:21

问题不是 git ls-remote 而是令牌。我在错误的地方调用了它。它需要在结帐步骤中设置,而不是在设置节点步骤中设置。这是我的工作 yaml,它允许我使用使用 oauth 令牌的私有存储库和标签来运行工作流程。唯一需要的设置是创建一个名为 GIT_TOKEN (或任何您想要的名称)的秘密并为其提供工作流访问权限。

name: API auto test and lint workflow

on: push

jobs:
  build:

    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          token: ${{ secrets.GIT_TOKEN }}
      - uses: actions/setup-node@v1
        with:
          node-version: 16.x
      - run: npm ci
      - run: npm run lint
      - run: npm run test

The problem wasn't git ls-remote it was the token. I was calling it in the wrong place. It needs to be set in the checkout step, not setup-node step. Here is my working yaml that allows me to run a workflow with a private repo and tag that uses an oauth token. The only setup needed is to make a secret called GIT_TOKEN (or whatever you want to call it) and give it workflow access.

name: API auto test and lint workflow

on: push

jobs:
  build:

    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          token: ${{ secrets.GIT_TOKEN }}
      - uses: actions/setup-node@v1
        with:
          node-version: 16.x
      - run: npm ci
      - run: npm run lint
      - run: npm run test
海风掠过北极光 2025-01-17 11:06:21

更快的方法是在 - run: npm ci 之前添加以下步骤:

run: |
      git config --local --name-only --get-regexp 'http.https://github.com/.extraheader' && git config --local --unset-all 'http.https://github.com/.extraheader' || :

A faster way is to add the following steps before - run: npm ci:

run: |
      git config --local --name-only --get-regexp 'http.https://github.com/.extraheader' && git config --local --unset-all 'http.https://github.com/.extraheader' || :
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文