Skip to content

Commit

Permalink
Create create-tag.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
cubxxw authored Nov 3, 2023
1 parent 73ae9cb commit 32adb8a
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/create-tag.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: OpenIM Create Tag

on:
issue_comment:
types: [created]
pull_request_review_comment:
types: [created]

jobs:
create_tag:
runs-on: ubuntu-latest
if: startsWith(github.event.comment.body, '/create tag')
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Create a new tag
env:
GH_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }}
run: |
# Extract version number and tag comment from the issue or pull request comment
COMMENT="${{ github.event.comment.body }}"
VERSION=$(echo "$COMMENT" | awk -F ' ' '{print $3}')
TAG_COMMENT=$(echo "$COMMENT" | awk -F '"' '{print $2}')
# Validate version number
if ! [[ $VERSION =~ ^v([0-9]+\.){2}[0-9]+$ ]]; then
echo "Invalid version number: $VERSION"
echo "The version number must match the pattern 'vX.Y.Z' where X, Y, and Z are integers."
exit 1
fi
# Create and push the tag
git tag -a "$VERSION" -m "$TAG_COMMENT"
git push origin "$VERSION"
echo "Tag '$VERSION' created with comment: $TAG_COMMENT"
# Set output for subsequent steps, if necessary
echo "tag_created=$VERSION" >> $GITHUB_ENV

0 comments on commit 32adb8a

Please sign in to comment.