Problem: I have Github Actions that automatically create a new release when certain tag is pushed. The only way to create tag from github web interface is to create a new release. The Actions[1] I'm using however failed with error message:-
Validation Failed: {"resource":"Release","code":"already_exists","field":"tag_name"}
If the tag was created from release.
We can create the tag using another Actions, there are a number of Actions that provide that. First I try using Github Script:-
name: "create-tag"
on:
workflow_dispatch:
inputs:
tagname:
description: 'Enter tag'
required: true
type: string
jobs:
create_tag:
name: "Create tag"
runs-on: "ubuntu-latest"
steps:
- name: Create tag ${{ inputs.tagname }}
uses: actions/github-script@v5
with:
script: |
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'refs/tags/${{ inputs.tagname }}',
sha: context.sha
})
For some reason that doesn't trigger push event though. So I try rickstaa/action-create-tag@v1 but also it didn't trigger push event. This second event is just using plain `git push ...` to push the tag instead of using the REST API, so it's weird that it doesn't trigger the push event.
[1]: marvinpinto/action-automatic-releases@latest