---
name: Sync tags with ansible-core releases

"on":
  workflow_dispatch:
    inputs:
      dry-run:
        type: boolean
        default: false
        description: "Select to run the tag script in dry-run mode"
  schedule:
    - cron: "0 * * * *"  # Hourly

permissions:
  contents: read  # read-only because we use bot token to push

jobs:
  tag:
    runs-on: "ubuntu-latest"
    environment: github-bot
    permissions:
      contents: write
    steps:
      - name: Generate temp GITHUB_TOKEN
        id: create_token
        uses: actions/create-github-app-token@v3
        with:
          app-id: ${{ secrets.BOT_APP_ID }}
          private-key: ${{ secrets.BOT_APP_KEY }}
      - name: Check out us
        uses: actions/checkout@v6
        with:
          path: ansible-documentation
          fetch-depth: 0
          token: "${{ steps.create_token.outputs.token }}"
          persist-credentials: true
      - name: Check out core
        uses: actions/checkout@v6
        with:
          repository: ansible/ansible
          path: ansible
          fetch-depth: 0
          persist-credentials: false
      - name: Setup nox
        uses: wntrblm/nox@2026.02.09
        with:
          python-versions: "3.12"
      - name: Set up git committer
        run: |
          ./hacking/get_bot_user.sh "ansible-documentation-bot" "Ansible Documentation Bot"
        working-directory: ansible-documentation
      - name: Run tag script
        run: nox -s tag -- tag ${{ inputs.dry-run && '--no-push' || '' }}
        working-directory: ansible-documentation
