Skip to content

Create Tag from .version File #5

Create Tag from .version File

Create Tag from .version File #5

name: Create Tag from .version File
permissions: read-all
on:
workflow_dispatch:
push:
paths:
- ".version" # Trigger only when the .version file changes
branches:
- main
jobs:
create_tag:
runs-on: ubuntu-24.04
permissions:
contents: write
steps:
# Checkout the repository
- name: Checkout repository
uses: actions/[email protected]
# Read the content of the .version file
- name: Read version from .version file
id: read_version
run: |
if [ ! -f .version ]; then
echo "The .version file does not exist."
exit 1
fi
version=$(cat .version | tr -d '[:space:]')
echo "version=$version" >> $GITHUB_ENV
# Create a tag with the version
- name: Create and push tag
env:
GH_TOKEN: ${{ secrets.CISCO_SERVICE_GITHUB_AUTOMATION_TOKEN }}
run: |
git config user.name cisco-service
git config user.email [email protected]
git remote set-url origin https://${GH_TOKEN}@github.com/${{ github.repository }}
git tag $version
git push origin $version