summaryrefslogtreecommitdiff
path: root/.github/workflows/checkandformat.yml
blob: 8bd9a8328ef81f6e97f0bedad12539b527af3c13 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
name: check and format flake

on:
  pull_request:
    paths:
      - "**.nix"
  push:
    paths:
      - "**.nix"
  workflow_dispatch:

jobs:
  check:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3

      - uses: cachix/install-nix-action@v19
        with:
          github_access_token: ${{ secrets.GITHUB_TOKEN }}

      - run: |
          export NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM=1
          export NIXPKGS_ALLOW_BROKEN=1
          nix flake check --impure
  format:
    if: ${{ github.event_name != 'pull_request' }}
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
        with:
          repository: ${{ github.event.pull_request.head.repo.full_name }}
          ref: ${{ github.event.pull_request.head.ref }}

      - uses: cachix/install-nix-action@v19
        with:
          github_access_token: ${{ secrets.GITHUB_TOKEN }}

      - run: nix fmt

      - uses: EndBug/add-and-commit@v9
        with:
          default_author: github_actions
          message: "chore: format flake"