1

我使用以下 GitHub Actions(新YAML版本)工作流程从我的lernamonorepo 发布包以推送到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:cinpm 脚本执行以下 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)

是什么导致了上述错误?

4

1 回答 1

1

您看到的错误“src refspec refs/heads/master 匹配多个”意味着您尝试推送的内容匹配多个修订。例如,如果给出的 refspec 是 ,master那么可能的情况是您同时拥有一个名为 的分支和一个标签master,而 Git 不知道您要推送哪个。

在这种情况下,您可能有一个分支和标签都已命名master,或者您有一个refs/heads/mastermaster分支)和一个refs/heads/refs/heads/master(这是refs/heads/master分支)或refs/tags/refs/heads/master(这是refs/heads/master标签),Git 会感到困惑。

您似乎正在尝试删除master脚本中的标签,这可能是您问题的根源。您可能希望修复导致创建该标签的任何原因,以便您不再遇到此问题。但是,如果没有看到您的回购,很难确切地说出这里的原因是什么。

于 2019-09-08T18:36:09.480 回答