name: Update flake.lock

on:
  push:
    branches: [master]
    paths: [go.sum]

jobs:
  update:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6

      - uses: DeterminateSystems/nix-installer-action@main

      - name: Update flake.lock
        run: nix flake update

      - name: Commit changes
        run: |
          git diff --quiet flake.lock && exit 0
          git config user.name "github-actions[bot]"
          git config user.email "github-actions[bot]@users.noreply.github.com"
          git add flake.lock
          git commit -m "chore: update flake.lock [skip ci]"
          git push
