name: 💡User-Agent Update

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

jobs:
   build:
     runs-on: ubuntu-latest
     steps:
       - name: Checkout Repo
         uses: actions/checkout@v4
         with:
           fetch-depth: 0

       - name: Setup golang
         uses: actions/setup-go@v4
         with:
           go-version: 1.24.x

       - name: Update User-Agents Data
         env:
            WHATISMYBROWSER_KEY: ${{ secrets.WHATISMYBROWSER_KEY }}
         run: |
           go run .
         working-directory: cmd/update-useragent

       - name: Create Pull Request
         uses: peter-evans/create-pull-request@v6
         with:
           token: ${{ secrets.GITHUB_TOKEN }}
           commit-message: "Weekly useragent update"
           title: "Weekly useragent update"
           body: "This PR updates the useragent data."
           branch: 'useragent-update'
           delete-branch: true
           base: 'main'
