-
Notifications
You must be signed in to change notification settings - Fork 1
129 lines (123 loc) · 4.09 KB
/
nix.yml
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
name: Build nix packages
on:
workflow_dispatch:
inputs:
host:
description: "which host profile to build"
type: string
required: true
default: "cicd-x86_64-linux"
nix-system:
description: "which system this host uses"
type: string
required: true
default: "x86_64-linux"
deploy-to-node:
description: "deploy to nodes"
type: boolean
default: false
required: false
free-disk-space:
description: "free disk space"
type: boolean
default: true
required: false
ignore-errors:
description: "ignore errors"
type: boolean
default: false
required: false
update-nix-inputs:
description: "update nix inputs"
type: boolean
default: false
required: false
pull_request:
branches:
- master
- main
- actions
- ci
- "releases/*"
paths:
- "*.nix"
- "**/*.nix"
- "nix/**"
- "flake.lock"
push:
branches:
- master
- main
- actions
- ci
- "releases/*"
paths:
- ".github/workflows/nix*.yml"
- "*.nix"
- "**/*.nix"
- "nix/**"
- "flake.lock"
schedule:
- cron: "0 16 * * 1"
- cron: "0 16 * * 5"
jobs:
build-packages:
if: github.event_name != 'workflow_dispatch' && github.event_name != 'schedule'
uses: ./.github/workflows/nix-large-packages.yml
build-nixos:
if: github.event_name != 'workflow_dispatch' && github.event_name != 'schedule'
strategy:
matrix:
include:
- host: "cicd-x86_64-linux"
nix-system: "x86_64-linux"
- host: "cicd-aarch64-linux"
nix-system: "aarch64-linux"
ignore-errors: true
uses: ./.github/workflows/nixos.yml
with:
host: "${{ matrix.host || 'cicd-x86_64-linux' }}"
nix-system: "${{ matrix.nix-system || 'x86_64-linux' }}"
deploy-to-node: "${{ matrix.deploy-to-node || false }}"
free-disk-space: "${{ matrix.free-disk-space || false }}"
ignore-errors: "${{ matrix.ignore-errors || false }}"
update-nix-inputs: "${{ matrix.update-nix-inputs || false }}"
secrets: inherit
build-nixos-when-needed:
if: github.event_name == 'workflow_dispatch' || github.event_name == 'schedule'
uses: ./.github/workflows/nixos.yml
with:
host: "${{ inputs.host || 'cicd-x86_64-linux' }}"
nix-system: "${{ inputs.nix-system || 'x86_64-linux' }}"
deploy-to-node: "${{ inputs.deploy-to-node || false }}"
free-disk-space: "${{ inputs.free-disk-space || github.event_name == 'schedule' }}"
ignore-errors: "${{ inputs.ignore-errors || false }}"
update-nix-inputs: "${{ inputs.update-nix-inputs || github.event_name == 'schedule' }}"
secrets: inherit
build-packages-when-needed:
needs:
- build-nixos-when-needed
if: needs.build-nixos-when-needed.outputs.shouldPushUpdates == 'yes'
uses: ./.github/workflows/nix-large-packages.yml
with:
branch: ${{ needs.build-nixos-when-needed.outputs.branch }}
create-pull-request-when-needed:
runs-on: ubuntu-latest
needs:
- build-nixos-when-needed
- build-packages-when-needed
if: needs.build-nixos-when-needed.outputs.shouldPushUpdates == 'yes'
steps:
- name: create or update pull request
run: |
repo="${{ github.repository }}"
base="${{ github.event.repository.default_branch }}"
head="${{ needs.build-nixos-when-needed.outputs.branch }}"
link="[github action run log](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})"
if id="$(gh pr -R "$repo" list -B "$base" -H "$head" --json number --limit 1 --jq '.[].number')" && [[ -n "$id" ]]; then
gh pr -R "$repo" comment "$id" --body "PR updated. See $link."
else
gh pr -R "$repo" create -B "$base" -H "$head" --title 'update nix flake inputs' --body "Created by Github action. See $link."
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}