[英]Repo not found using semantic-release-monorepo in GitHub Actions workflow
I am creating a GitHub Actions workflow to build and publish npm packages to GitHub Packages.我正在创建 GitHub 操作工作流来构建 npm 包并将其发布到 GitHub 包。 The repo is a monorepo with several packages, so I am using the semantic-release-monorepo tool.
repo 是一个带有多个包的 monorepo,所以我使用了 semantic-release-monorepo 工具。 However, the step to publish is failing and I can't figure out why.
但是,发布步骤失败了,我不知道为什么。
My GitHub Actions workflow file is as follows (trimmed down slightly)我的 GitHub Actions 工作流文件如下(略减)
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
env:
GH_TOKEN: ${{ secrets.MY_PAT }}
steps:
- name: Checkout repo
uses: actions/checkout@v2
run: |
yarn install
yarn build
- name: Setup node for publishing to Github packages
uses: actions/setup-node@v2
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
node-version: "12.x"
registry-url: "https://npm.pkg.github.com"
- name: Yarn publish packages
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
yarn publish-packages
yarn publish-packages
runs a script which executes the lerna command for semantic release yarn publish-packages
运行一个脚本,该脚本执行 lerna 命令以进行语义发布
lerna exec --concurrency 1 -- npx --no-install semantic-release -e semantic-release-monorepo
I have made sure the repo package.json as well as the package.json for every package has the correct repository url, https://github.com/owner/repo.git
. I have made sure the repo package.json as well as the package.json for every package has the correct repository url,
https://github.com/owner/repo.git
. My personal access token has permissions to repo and write and delete packages.我的个人访问令牌有权回购、写入和删除包。
No matter what configs I change, the step fails with the following messages:无论我更改什么配置,该步骤都会失败并显示以下消息:
The command "git push --dry-run --no-verify https://[secure]@github.com/xxx/xxx.git HEAD:develop" failed with the error message remote: Repository not found.
命令“git push --dry-run --no-verify https://[secure]@github.com/xxx/xxx.git HEAD:develop”失败,并显示错误消息 remote: Repository not found。 26 fatal: repository 'https://github.com/xxx/xxx.git/' not found.
26 致命:未找到存储库“https://github.com/xxx/xxx.git/”。
The second message is第二条消息是
EGITNOPERMISSION: ' semantic-release cannot push the version tag to the branch
develop
on the remote Git repository with URLhttps://[secure]@github.com/xxx/xxx.git
EGITNOPERMISSION: ' semantic-release cannot push the version tag to the branch
develop
on the remote Git repository with URLhttps://[secure]@github.com/xxx/xxx.git
Other things I have tried:我尝试过的其他事情:
NODE_AUTH_TOKEN
by default.NODE_AUTH_TOKEN
的 .npmrc 文件。.git
to his repository url seems to have fixed it for him.git
添加到他的存储库 url 似乎已经为他解决了I've looked through the docs for semantic-release, semantic-release-monorepo, GitHub Actions, and GitHub Packages.我查看了语义发布、语义发布-monorepo、GitHub 操作和 GitHub 包的文档。 If there is any additional information I need to include please let me know.
如果我需要包含任何其他信息,请告诉我。
After some more trial and error, I discovered the cause.经过更多的尝试和错误,我发现了原因。 If my understanding is correct, a Github workflow will automatically use the available GITHUB_TOKEN secret to authenticate with Github during the step to checkout the repo using
actions/checkout
.如果我的理解是正确的,那么 Github 工作流程将在使用
actions/checkout
签出 repo 的步骤中自动使用可用的 GITHUB_TOKEN 密码向 Github 进行身份验证。 It was then persisting the credentials from this step and reusing them for the step to publish packages, even though I was injecting a personal access token as an environment variable to that step.然后,它保留了此步骤中的凭据并将其重新用于发布包的步骤,即使我将个人访问令牌作为环境变量注入该步骤。
In the end, the fix was to use the persist-credentials
option in step one like this最后,解决方法是在第一步中使用
persist-credentials
选项,如下所示
steps:
- name: Checkout repo
uses: actions/checkout@v2
with:
persist-credentials: false
And then using the personal access token to authenticate with GitHub in the last step like I noted I believed should be the correct method in my question, as semantic-release docs state only PAT authentication is supported.然后使用个人访问令牌在最后一步使用 GitHub 进行身份验证,就像我指出的那样,我认为这应该是我的问题中的正确方法,因为语义发布文档 state 仅支持 PAT 身份验证。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.