name: Auto Tag

on:
  push:
    branches:
      - main

permissions:
  contents: write

jobs:
  tag:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4

      - name: Generate tag
        id: tag
        run: |
          TAG="build-$(date +'%Y%m%d-%H%M%S')"
          echo "TAG=$TAG" >> $GITHUB_ENV

      - name: Create tag
        run: |
          git config user.name github-actions
          git config user.email github-actions@github.com
          git tag $TAG
          git push origin $TAG
