name: Check

on:
  push:
    branches:
      - main
  pull_request:
    types: [opened, reopened, edited, auto_merge_enabled]

jobs:
  check:
    name: check
    runs-on: ubuntu-latest
    if: |
      contains(github.event.head_commit.message, 'bump:') == false &&
      contains(github.event.head_commit.message, 'Merge pull request') == false
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Install Nix
        uses: cachix/install-nix-action@v31
        with:
          nix_path: nixpkgs=channel:nixos-unstable

      - name: Use Cachix
        uses: cachix/cachix-action@v16
        with:
          name: trevstack
          authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"

      - name: Check
        run: nix flake check
