softprops / action-gh-release

📦 :octocat: GitHub Action for creating GitHub Releases
MIT License
4.1k stars 450 forks source link

[{"resource":"Release","code":"already_exists","field":"tag_name"}] #375

Open AlbertXiaoPeng opened 1 year ago

AlbertXiaoPeng commented 1 year ago

My workflow.yml

name: REALEASE

on:
  push:
    tags:
      - "v*.*.*"

permissions:
  contents: write
  discussions: write

jobs:
  build:
    runs-on: ubuntu-latest
    name: production deploy
    steps:
      - uses: actions/checkout@v3
      - uses: pnpm/action-setup@v2
        with:
          version: 8
      - name: Use Node.js 16.x
        uses: actions/setup-node@v3
        with:
          node-version: 16.x
        env:
          CI: true
          PROGRESS: none
          NODE_ENV: test
          NODE_OPTIONS: --max_old_space_size=4096
      - name: pnpm install
        run: |
          echo ${{github.ref}}
          pnpm install
      - name: Build
        run: |
          echo ${{github.workspace}}
          pnpm build
      - name: Compress action step
        uses: a7ul/tar-action@v1.1.0
        id: compress
        with:
          command: c
          cwd: ./
          files: |
            ./apps/tools-site/dist
          outPath: tools-site.tar.gz
      - name: Release
        uses: softprops/action-gh-release@v1
        with:
          token: ${{secrets.CUSTOM_TOKEN}}
          name: ${{github.ref_name}}
          tag_name: ${{github.ref_name}}
          body_path: ./apps/tools-site/changelogs/${{github.ref_name}}.md
          discussion_category_name: Release
          files: tools-site.tar.gz

When I push a new tag, it starts to run the workflow, but it gives an error

👩‍🏭 Creating new GitHub release for tag v2.0.3...
⚠️ GitHub release failed with status: 404
undefined
retrying... (2 retries remaining)
👩‍🏭 Creating new GitHub release for tag v2.0.3...
⚠️ GitHub release failed with status: 4[22](https://github.com/xp-work/Test2/actions/runs/5655268949/job/15320028840#step:8:23)
[{"resource":"Release","code":"already_exists","field":"tag_name"}]
retrying... (1 retries remaining)
👩‍🏭 Creating new GitHub release for tag v2.0.3...
⚠️ GitHub release failed with status: 422
[{"resource":"Release","code":"already_exists","field":"tag_name"}]
retrying... (0 retries remaining)
❌ Too many retries. Aborting...
Error: Too many retries.

When I went to check Release, I found a new release, indicating that the release was successful, but an error was reported in the workflow

image

Please tell me how to handle de-posting from an already existing tag without getting an error?

Or whether it should be added to the publishing process to determine whether the tag exists before deciding on the following actions

multani commented 11 months ago

@AlbertXiaoPeng not sure if you find the problem. If not, can you check if you have the Discussions enabled in your repository and that the discussion_category_name name you use (Release in your example) is a valid category?

As mentioned in https://github.com/softprops/action-gh-release/issues/110#issuecomment-1793486584, the 404 when creating a release seems to be coming from the an invalid discussion category.