-
Notifications
You must be signed in to change notification settings - Fork 1
139 lines (122 loc) · 4.9 KB
/
build.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
130
131
132
133
134
135
136
137
138
139
name: "Build and populate cache"
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
build:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
name: Build
strategy:
fail-fast: false
matrix:
cachixName:
- reedrw
output:
- reed@nixos-desktop
- reed@nixos-t480
- reed@nixos-t400
- nixos-desktop-no-home-manager
- nixos-t480-no-home-manager
- nixos-t400-no-home-manager
- nixos-vm
- nix-shell
runs-on: ubuntu-latest
steps:
# # Uncomment if GitHub Actions jobs start failing from lack of space
# - name: Cleanup Disk
# uses: jlumbroso/free-disk-space@main
# Deleting android library saves ~14gb of space
- name: Cleanup Disk
run: sudo rm -rf /usr/local/lib/android
- name: Install Doppler CLI
uses: dopplerhq/cli-action@v3
- name: Pass all secrets to next steps
run: |
while read -rd $'' line; do echo "$line" >> $GITHUB_ENV; done < <( doppler secrets download --no-file --format=json | jq "." | grep -v 'DOPPLER_\(CONFIG\|ENVIRONMENT\|PROJECT\)' | jq -r 'to_entries|map("\(.key)<<EOF\n\(.value)\nEOF\u0000")[]' )
while read -r line; do echo "::add-mask::$line"; done < <( doppler secrets download --no-file --format=json | jq "." | grep -v 'DOPPLER_\(CONFIG\|ENVIRONMENT\|PROJECT\)' | jq -r 'to_entries|map("\(.value)\u0000")[]' )
env:
DOPPLER_TOKEN: ${{ secrets.DOPPLER_TOKEN }}
- uses: tibdex/[email protected]
if: ${{ github.event_name == 'pull_request' && github.head_ref == 'update-dependencies' }}
id: generate-token
with:
app_id: ${{ env.APP_ID }}
private_key: ${{ env.APP_PRIVATE_KEY }}
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@v16
with:
source-url: "https://install.lix.systems/lix/lix-installer-x86_64-linux"
logger: pretty
- name: Install Cachix
uses: cachix/cachix-action@v15
with:
name: ${{ matrix.cachixName }}
signingKey: '${{ env.CACHIX_SIGNING_KEY }}'
pushFilter: '(-source$|-src$|\.tar\.gz$|\.xpi$)'
- name: Build
run: |
set -x
if [[ "${{ matrix.output }}" == "nix-shell" ]]; then
buildCommand="nix develop --accept-flake-config --show-trace --command bash -c 'exit'"
else
buildCommand="./install.sh -v --build ${{ matrix.output }}"
fi
$buildCommand
env:
NIXPKGS_ALLOW_UNFREE: 1
- name: Calculate diff between closures
id: diff
continue-on-error: true
if: ${{ github.event_name == 'pull_request'
&& github.head_ref == 'update-dependencies'
&& matrix.output != 'nix-shell' }}
run: |
./install.sh -v --build ${{ matrix.output }} -o result-new
git checkout "$(git rev-parse @~)"
./install.sh -v --build ${{ matrix.output }} -o result-old
echo "diff_closure<<EOF" >> $GITHUB_ENV
# TODO remove pipe to sed when NixOS/nix#4626 is fixed
nix store diff-closures ./result-old ./result-new | sed 's/\x1b\[[0-9;]*m//g' >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
env:
NIXPKGS_ALLOW_UNFREE: 1
- name: Post diff to PR comment
if: ${{ steps.diff.outcome == 'success' && env.diff_closure != '' }}
uses: phulsechinmay/[email protected]
with:
message: |
### Closure diff for `${{ matrix.output }}`
```
${{ env.diff_closure }}
```
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
COMMENT_IDENTIFIER: closure-diff-${{ matrix.output }}
telegram:
name: Telegram
needs: build
runs-on: ubuntu-latest
if: always()
steps:
- name: Install Doppler CLI
uses: dopplerhq/cli-action@v3
- name: Pass all secrets to next steps
run: |
while read -rd $'' line; do echo "$line" >> $GITHUB_ENV; done < <( doppler secrets download --no-file --format=json | jq "." | grep -v 'DOPPLER_\(CONFIG\|ENVIRONMENT\|PROJECT\)' | jq -r 'to_entries|map("\(.key)<<EOF\n\(.value)\nEOF\u0000")[]' )
while read -r line; do echo "::add-mask::$line"; done < <( doppler secrets download --no-file --format=json | jq "." | grep -v 'DOPPLER_\(CONFIG\|ENVIRONMENT\|PROJECT\)' | jq -r 'to_entries|map("\(.value)\u0000")[]' )
env:
DOPPLER_TOKEN: ${{ secrets.DOPPLER_TOKEN }}
- name: Get workflow conclusion
uses: technote-space/[email protected]
- name: Send notification
uses: yanzay/[email protected]
with:
chat: ${{ env.NOTIFICATION_CHAT_ID }}
token: ${{ env.NOTIFICATION_TOKEN }}
status: ${{ env.WORKFLOW_CONCLUSION }}
if: env.WORKFLOW_CONCLUSION != 'success'