Reputation: 5836
I use the following GitHub Actions (new YAML
version) workflow to publish packages from my lerna
monorepo to push to 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/[email protected]
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/[email protected]
env:
BUILD_DIR: _site/
GH_PAT: ${{ secrets.GH_PAT }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
The deploy:ci
npm script executes the following bash script:
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:[email protected]/SCOPE/REPO_NAME.git"
git fetch
git tag -d master
echo "Configuring CI Git User..."
git config --global user.email [email protected]
git config --global user.name GitHub Actions
echo "Publishing Packages..."
npx lerna publish \
--message "chore: release new versions" \
--yes
that results in the following error:
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)
What is causing the above error?
Upvotes: 1
Views: 2456
Reputation: 76609
The error you're seeing, "src refspec refs/heads/master matches more than one", means that what you're trying to push matches more than one revision. If the refspec given were, say, master
, then the likely situation is that you have both a branch and a tag called master
, and Git wouldn't know which one you wanted to push.
In this case, it's possible that you have either a branch and tag both named master
or you have a refs/heads/master
(the master
branch) and either a refs/heads/refs/heads/master
(which is the refs/heads/master
branch) or refs/tags/refs/heads/master
(which is the refs/heads/master
tag), and Git is getting confused.
It looks like you're trying to delete a master
tag in your script, which is likely the source of your issues. You'll probably want to fix whatever is causing that tag to be created so that you don't have this issue anymore. Without seeing your repo, though, it's hard to tell exactly what the cause is here.
Upvotes: 1