Skip to content

Commit 0f235bc

Browse files
committed
Add workflow to create Git tags
This workflow allows users to create a Git tag through the GitHub Actions interface, checking for existing tags before creation.
1 parent 79ae003 commit 0f235bc

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

.github/workflows/create-tag.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Create Git Tag
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
tag_name:
7+
description: "Tag name (eg. v1.3.0)"
8+
required: true
9+
type: string
10+
11+
permissions:
12+
contents: write
13+
14+
jobs:
15+
create_tag:
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0
23+
persist-credentials: false
24+
25+
- name: Configure git with PAT
26+
run: |
27+
git config user.name "github-actions[bot]"
28+
git config user.email "github-actions[bot]@users.noreply.github.com"
29+
git remote set-url origin "https://x-access-token:${{ secrets.PAT_BLADEX_PUSH }}@github.com/${{ github.repository }}.git"
30+
31+
- name: Check if the tag is already existing
32+
run: |
33+
TAG="${{ inputs.tag_name }}"
34+
git fetch --tags
35+
if git rev-parse -q --verify "refs/tags/$TAG" >/dev/null; then
36+
echo "❌ Tag $TAG already exists"
37+
exit 1
38+
fi
39+
40+
- name: Create and push the tag
41+
run: |
42+
TAG="${{ inputs.tag_name }}"
43+
git tag "$TAG"
44+
git push origin "$TAG"

0 commit comments

Comments
 (0)