Skip to content

Create new tag on repository dispatch #4

Create new tag on repository dispatch

Create new tag on repository dispatch #4

name: Create new tag on dispatch
on:
workflow_dispatch:
repository_dispatch:
types: [sveltia-cms-publish] # Specify your custom event type here
jobs:
create_tag:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
ref: exp-cc-v4
- name: Get current date
id: date
run: echo "DATE=$(date +'%Y%m%d')" >> $GITHUB_ENV
- name: Determine tag sequence number
id: tag_number
run: |
BRANCH_NAME=exp-cc-v4
DATE=$(date +'%Y%m%d')
TAG_PREFIX="${BRANCH_NAME}-${DATE}"
EXISTING_TAGS=$(git tag --list "${TAG_PREFIX}-*")
if [ -z "$EXISTING_TAGS" ]; then
SEQUENCE=1
else
SEQUENCE=$(echo "$EXISTING_TAGS" | awk -F '-' '{print $NF}' | sort -n | tail -1)
SEQUENCE=$((SEQUENCE + 1))
fi
echo "TAG_NAME=${TAG_PREFIX}-${SEQUENCE}" >> $GITHUB_ENV
- name: Create a new tag
run: |
git tag ${{ env.TAG_NAME }}
git push origin ${{ env.TAG_NAME }}
env:
GITHUB_TOKEN: ${{ secrets.API_TOKEN_GITHUB }}