Create Tag #5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Create Tag | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| action: | |
| description: 'push or delete' | |
| required: false | |
| type: choice | |
| default: push | |
| options: | |
| - push | |
| - delete | |
| tag: | |
| description: 'Tag name' | |
| required: true | |
| type: string | |
| message: | |
| description: 'Tag message (used when action is push)' | |
| required: false | |
| type: string | |
| default: '' | |
| jobs: | |
| tag-job: | |
| name: Tag ${{ inputs.action }} | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: main | |
| fetch-depth: 0 | |
| - name: Push tag | |
| if: inputs.action == 'push' | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| if [ -n "${{ inputs.message }}" ]; then | |
| git tag -a "${{ inputs.tag }}" -m "${{ inputs.message }}" | |
| else | |
| git tag "${{ inputs.tag }}" | |
| fi | |
| git push origin "${{ inputs.tag }}" | |
| - name: Delete tag | |
| if: inputs.action == 'delete' | |
| run: git push origin --delete "${{ inputs.tag }}" |