git - 通过 GitHub Actions 将 Lerna Monorepo 发布到 NPM 时出现 Git 错误
问题描述
我使用以下 GitHub Actions(新YAML
版本)工作流程从我的lerna
monorepo 发布包以推送到master
:
name: CD
on:
push:
branches:
- master
jobs:
deployPackages:
name: Deploy Packages
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Checkout master
run: git checkout master
- name: Install
uses: nuxt/actions-yarn@master
with:
args: install
- name: Build
uses: nuxt/actions-yarn@master
with:
args: build
- name: Lint
uses: nuxt/actions-yarn@master
with:
args: lint
- name: Test
uses: ianwalter/puppeteer@v1.0.0
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
with:
entrypoint: yarn
args: test:ci
- name: Deploy Packages
uses: nuxt/actions-yarn@master
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
DEPLOYING_USER_NAME: ${{ secrets.DEPLOYING_USER_NAME }}
GH_PAT: ${{ secrets.GH_PAT }}
with:
args: deploy:ci
- name: Build Docs
uses: nuxt/actions-yarn@master
with:
args: docs
- name: Deploy Docs
uses: maxheld83/ghpages@v0.2.1
env:
BUILD_DIR: _site/
GH_PAT: ${{ secrets.GH_PAT }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
deploy:ci
npm 脚本执行以下 bash 脚本:
echo "Authenticating with Registry..."
npm config set registry //registry.npmjs.org/:_authToken=$NPM_TOKEN -q
echo "Adding Git Remote..."
git remote rm origin
git remote add origin "https://$DEPLOYING_USER_NAME:$GH_PAT@github.com/SCOPE/REPO_NAME.git"
git fetch
git tag -d master
echo "Configuring CI Git User..."
git config --global user.email octobot@github.com
git config --global user.name GitHub Actions
echo "Publishing Packages..."
npx lerna publish \
--message "chore: release new versions" \
--yes
这会导致以下错误:
lerna info execute Skipping releases
lerna info git Pushing tags...
lerna ERR! Error: Command failed: git push --follow-tags --no-verify origin master
lerna ERR! error: src refspec refs/heads/master matches more than one.
lerna ERR! fatal: The remote end hung up unexpectedly
lerna ERR! error: failed to push some refs to 'https://***:***@github.com/SCOPE/REPO_NAME.git'
lerna ERR!
lerna ERR! at makeError (/github/workspace/node_modules/execa/index.js:174:9)
lerna ERR! at Promise.all.then.arr (/github/workspace/node_modules/execa/index.js:278:16)
是什么导致了上述错误?
解决方案
您看到的错误“src refspec refs/heads/master 匹配多个”意味着您尝试推送的内容匹配多个修订。例如,如果给出的 refspec 是 ,master
那么可能的情况是您同时拥有一个名为 的分支和一个标签master
,而 Git 不知道您要推送哪个。
在这种情况下,您可能有一个分支和标签都已命名master
,或者您有一个refs/heads/master
(master
分支)和一个refs/heads/refs/heads/master
(这是refs/heads/master
分支)或refs/tags/refs/heads/master
(这是refs/heads/master
标签),Git 会感到困惑。
您似乎正在尝试删除master
脚本中的标签,这可能是您问题的根源。您可能希望修复导致创建该标签的任何原因,以便您不再遇到此问题。但是,如果没有看到您的回购,很难确切地说出这里的原因是什么。
推荐阅读
- database - 为不同的应用程序使用相同的用户名/密码数据库?
- javascript - 还有另一种获取地图的方法吗?
- slack - 发送消息时松弛 channel_not_found
- ios - 'EnumeratedSequence<[CGPoint]>' 类型的值没有成员 'compactMap'
- python - c程序SWIG到python给出'ImportError:动态模块没有定义init函数'
- java - 使用 java api 进行 rsa 签名并使用 biginteger 进行验证
- matlab - 绘制许多具有不同和可区分颜色的图形
- ssl - 带有内部 DNS 的 SAN 证书
- css - 两种布局(前台和管理员)的 css 在生产模式下不起作用
- video - 我怎样才能解复用/重新复用视频流 h264?