name: badges
on:
  schedule:
    - cron: '0 * * * *'
  workflow_dispatch:

env:
  PYTHONPATH: ${{ github.workspace }}

jobs:
  badges:
    name: create badges
    runs-on: ubuntu-latest
    if: github.repository == 'sunnypilot/sunnypilot'
    permissions:
      contents: write
    steps:
    - uses: actions/checkout@v6
      with:
        submodules: true
    - run: ./tools/op.sh setup
    - name: Push badges
      run: |
        python3 selfdrive/ui/translations/create_badges.py

        rm .gitattributes

        git checkout --orphan badges
        git rm -rf --cached .
        git config user.email "badge-researcher@sunnypilot.ai"
        git config user.name "Badge Researcher"

        git add translation_badge.svg
        git commit -m "Add/Update badges"
        git push -f origin HEAD
