name: Audit

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

concurrency:
  group: audit-${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

jobs:
  cargo-audit:
    name: Cargo audit
    runs-on: ubuntu-latest

    steps:
      - name: Check out repository
        uses: actions/checkout@v6
        with:
          submodules: recursive

      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable

      - name: Cache cargo artifacts
        uses: Swatinem/rust-cache@v2

      - name: Install cargo-audit
        run: cargo install cargo-audit --locked

      - name: Run cargo audit
        run: cargo audit
