create-release icon indicating copy to clipboard operation
create-release copied to clipboard

accidentally create a release for master branch make later push to master fail

Open chinglinwen opened this issue 5 years ago • 13 comments

Here's the workflows, which should run when tag event happen, but I accidentally comments out those filter, so it create a release tag with name (refs/heads/master) , which cause later push to remote master fail.

I don't found anyway to delete that tag on github, I fixed by delete repository first then recreate again ( which all activities and release are lost, so this sould not happen ).

[wen@234 k8snew actiontest]$ git push origin master
error: dst refspec refs/heads/master matches more than one.
error: failed to push some refs to 'https://github.com/chinglinwen/actiontest.git'
[wen@234 k8snew actiontest]$ git push origin --delete refs/heads/master
error: dst refspec refs/heads/master matches more than one.
error: failed to push some refs to 'https://github.com/chinglinwen/actiontest.git'
[wen@234 k8snew actiontest]$ git tag
2019-10-29
refs/heads/master
v0.0.1
[wen@234 k8snew actiontest]$
on:
  push:
    # Sequence of patterns matched against refs/tags
    # tags:
    #   - "v*" # Push events to matching v*, i.e. v1.0, v20.15.10

name: Upload Release Asset

jobs:
  build:
    name: Upload Release Asset
    runs-on: ubuntu-latest
    steps:
      - name: Set up Go 1.13
        uses: actions/setup-go@v1
        with:
          go-version: 1.13
        id: go

      - name: Check out code into the Go module directory
        uses: actions/checkout@v1

      - name: Get dependencies
        run: |
          go get -v -t -d ./...
          if [ -f Gopkg.toml ]; then
              curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
              dep ensure
          fi

      - name: Build
        run: |
          go build -v .
          echo run actiontest

      - name: Build project # This would actually build your project, using zip for an example artifact
        run: |
          zip --junk-paths actiontest actiontest README.md
      - name: Create Release
        id: create_release
        uses: actions/[email protected]
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          tag_name: ${{ github.ref }}
          release_name: Release ${{ github.ref }}
          draft: false
          prerelease: false
      - name: Upload Release Asset
        id: upload-release-asset
        uses: actions/[email protected]
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
          asset_path: ./actiontest.zip
          asset_name: actiontest.zip
          asset_content_type: application/zip

chinglinwen avatar Oct 29 '19 02:10 chinglinwen

This is an issue yes.

TheBlackPlague avatar Dec 17 '19 14:12 TheBlackPlague

You can delete the remote tag by git push origin :refs/tags/refs/heads/master.

k-takata avatar Dec 24 '19 07:12 k-takata

@k-takata Yes.

While that exists, it's still not appropriate for this action to mess the tags up.

TheBlackPlague avatar Dec 25 '19 15:12 TheBlackPlague

Thanks @k-takata ! I had to delete the tag both remotely and locally:

git push origin :refs/tags/refs/heads/master
git tag -d refs/heads/master

tekumara avatar May 17 '20 04:05 tekumara

Same issue here.

StephanMeijer avatar May 18 '20 10:05 StephanMeijer

Ugh, is there no workaround for this? I was trying to migrate a project that only maintains a single release for the master branch. Now, while the build works, you can't push any changes unless you first delete the tag. I can't use the commit SHA for a release name because that gets rejected by the API.

ndarilek avatar May 18 '20 16:05 ndarilek

I have seen the same issue when trying to filter by tags + branches. It works fine if i only filter by tags. Is it the case that GitHub's filtering is OR?

name: release

on:
  push:
    # Sequence of patterns matched against refs/heads
    branches:    
      - master
    # Sequence of patterns matched against refs/tags
    tags:        
      - v*

jobs:
  release:
    name: Create Release
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v2
      - name: Create Release
        id: create_release
        uses: actions/create-release@v1
        env:
          # When you use the repository's GITHUB_TOKEN to perform tasks on behalf of the GitHub Actions app, events triggered by the GITHUB_TOKEN will not create a new workflow run. 
          GITHUB_TOKEN: ${{secrets.PERSONAL_TOKEN}}
        with:
          tag_name: ${{ github.ref }}
          release_name: Release ${{ github.ref }}
          draft: false
          prerelease: false

This workflow will create Release refs/heads/master

jacktuck avatar Jun 16 '20 13:06 jacktuck

Same issue here.

git push --follow-tags origin main
name: Create Release

on:
  push:
    branches:
      - main
    # Sequence of patterns matched against refs/tags
    tags:
      - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10

jobs:
  build:
    name: Create Release
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v2
        with:
          fetch-depth: 0 # This is important for the Git history
      - name: Extract Repo Attributes
        id: attrs # This is important for future referencing
        uses: ibnesayeed/repo-attrs@master
      - name: Create Release
        id: create_release
        uses: actions/create-release@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
        with:
          tag_name: ${{ github.ref }}
          release_name: Release ${{ github.ref }}
          body: |
            ## Changes in this Release

            History from `${{ steps.attrs.outputs.tail }}` to `${{ steps.attrs.outputs.head }}`

            ### Commits

            ${{ steps.attrs.outputs.commits }}

            ### Pull Requests

            ${{ steps.attrs.outputs.prs }}

            ### Contributors

            ${{ steps.attrs.outputs.contributors }}

            ### Files

            ```
            ${{ steps.attrs.outputs.files }}
            ```
          draft: false
          prerelease: false

daolou avatar Jul 21 '20 04:07 daolou

rm branches: - main and it work

daolou avatar Jul 21 '20 07:07 daolou

faced same issue today and this worked for me

fawazahmed0 avatar Dec 25 '20 22:12 fawazahmed0

I was forced to change the tag name to something static and keep the release name.

mwanjajoel avatar Jan 04 '21 15:01 mwanjajoel

I was forced to change the tag name to something static and keep the release name.

Though this works only once and so is not recommended as its a temporary solution

mwanjajoel avatar Jan 04 '21 15:01 mwanjajoel

incredible

deltanedas avatar Feb 03 '21 18:02 deltanedas