Skip to content

Commit 7374245

Browse files
committed
pr ci flow
1 parent e8f4657 commit 7374245

1 file changed

Lines changed: 16 additions & 6 deletions

File tree

.github/workflows/build.yaml

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
name: build
22

33
on:
4+
pull_request:
45
push:
56
branches: [master]
67
workflow_dispatch:
78

89
permissions:
910
contents: read
1011

12+
concurrency:
13+
group: ${{ github.workflow }}-${{ github.ref }}
14+
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
15+
1116
jobs:
1217
check:
1318
name: Flake check + format
@@ -19,12 +24,13 @@ jobs:
1924
- run: nix fmt . && git diff --exit-code
2025

2126
build:
22-
name: Build + push ${{ matrix.system }}
27+
name: Build ${{ matrix.system }}
2328
needs: check
2429
runs-on: ${{ matrix.runner }}
2530
permissions:
2631
contents: read
2732
packages: write
33+
actions: write # cache purge
2834
strategy:
2935
fail-fast: false
3036
matrix:
@@ -39,21 +45,25 @@ jobs:
3945
with:
4046
primary-key: nix-${{ matrix.system }}-${{ hashFiles('flake.lock', 'flake.nix', 'modules/**', 'packages/**') }}
4147
restore-prefixes-first-match: nix-${{ matrix.system }}-
48+
# PR saves count against the repo quota and would evict master's caches.
49+
save: ${{ github.event_name != 'pull_request' }}
4250
gc-max-store-size-linux: 6G
4351
purge: true
4452
purge-prefixes: nix-${{ matrix.system }}-
4553
purge-created: 0
4654
purge-primary-key: never
47-
- name: Build + push ${{ matrix.system }}
55+
- name: Build ${{ matrix.system }}
56+
# out-link roots the image closure so the pre-save GC keeps it.
57+
run: nix build .#packages.${{ matrix.system }}.exedev --out-link /tmp/image
58+
- name: Push ${{ matrix.system }}
59+
if: github.event_name != 'pull_request'
4860
env:
4961
GHCR_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50-
run: |
51-
# out-link roots the image closure so the pre-save GC keeps it.
52-
nix build .#packages.${{ matrix.system }}.exedev --out-link /tmp/image
53-
nix run .#push-image -- ${{ matrix.system }}
62+
run: nix run .#push-image -- ${{ matrix.system }}
5463

5564
manifest:
5665
name: Publish multi-arch manifest
66+
if: github.event_name != 'pull_request'
5767
needs: build
5868
runs-on: ubuntu-24.04
5969
permissions:

0 commit comments

Comments
 (0)