name: Audit
on:
  pull_request:
  push:
    branches:
      - main
    paths:
      - '.github/workflows/audit.yml'
      - '**/Cargo.toml'
      - '**/Cargo.lock'
      - '**/Cargo.nix.lock'
      - '**/audit.toml'
  schedule:
    - cron: '0 0 * * *'
  workflow_dispatch:

jobs:
  audit:
    name: Audit
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: cachix/install-nix-action@v31
      - uses: cachix/cachix-action@v16
        with:
          name: devenv
      - name: Install devenv.sh
        run: nix profile install nixpkgs#devenv
      - name: Audit
        run: |
          devenv shell just audit
  check-licenses:
    name: Check licenses
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: cachix/install-nix-action@v31
      - uses: cachix/cachix-action@v16
        with:
          name: devenv
      - name: Install devenv.sh
        run: nix profile install nixpkgs#devenv
      - name: Audit
        run: |
          devenv shell just check-licenses
