Kernels
wyldecat commited on
Commit
5dde6fa
·
1 Parent(s): a1e5ca8

chore: add build action [skip-build]

Browse files
.github/actionlint.yaml ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ self-hosted-runner:
2
+ labels:
3
+ - docker-builder-01
.github/workflows/build-and-commit.yml ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Nix build and commit
2
+
3
+ on:
4
+ pull_request:
5
+ types: [opened, synchronize, reopened]
6
+ workflow_dispatch:
7
+
8
+ permissions:
9
+ contents: write
10
+
11
+ jobs:
12
+ check-commit:
13
+ runs-on: ubuntu-latest
14
+ outputs:
15
+ skip: ${{ steps.check.outputs.skip }}
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+ with:
19
+ fetch-depth: 0
20
+ - id: check
21
+ run: |
22
+ if [ "${{ github.event_name }}" = "pull_request" ]; then
23
+ msg=$(git log -1 --pretty=%B "${{ github.event.pull_request.head.sha }}")
24
+ else
25
+ msg="manual dispatch"
26
+ fi
27
+ echo "Commit message: $msg"
28
+ if echo "$msg" | grep -q '\[skip-build\]'; then
29
+ echo "skip=true" >> "$GITHUB_OUTPUT"
30
+ else
31
+ echo "skip=false" >> "$GITHUB_OUTPUT"
32
+ fi
33
+
34
+ build_and_commit:
35
+ needs: check-commit
36
+ if: needs.check-commit.outputs.skip == 'false'
37
+ runs-on: docker-builder-01
38
+ steps:
39
+ - name: Show disk usage
40
+ run: df -h
41
+
42
+ - name: Checkout repository
43
+ uses: actions/checkout@v4
44
+ with:
45
+ fetch-depth: 0
46
+ lfs: true
47
+ ref: ${{ github.head_ref || github.ref }}
48
+
49
+ - name: Install Nix
50
+ uses: cachix/install-nix-action@v31
51
+
52
+ - name: Setup huggingface cachix
53
+ uses: cachix/cachix-action@v15
54
+ with:
55
+ name: huggingface
56
+
57
+ - name: Clean build directory
58
+ run: |
59
+ rm -rf build
60
+
61
+ - name: Build with Nix
62
+ run: |
63
+ nix run .#build-and-copy \
64
+ --override-input kernel-builder github:huggingface/kernel-builder \
65
+ --max-jobs 8 \
66
+ -j 8 \
67
+ -L
68
+
69
+ - name: List built binaries
70
+ run: |
71
+ ls build
72
+
73
+ - name: Commit build artifact
74
+ run: |
75
+ git config user.name "github-actions[bot]"
76
+ git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
77
+ git add build/*
78
+ git commit -m "Add built binary [skip-build]"
79
+
80
+ - name: Push changes
81
+ run: |
82
+ git push origin HEAD:"$HEAD_REF"
83
+ env:
84
+ HEAD_REF: ${{ github.head_ref || github.ref }}
85
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}