Skip to content

Commit c2c59d4

Browse files
committed
ci(gh-actions/workflows/ci): Allow passing custom GITHUB_TOKEN to use as Nix access-token
1 parent 4b4525f commit c2c59d4

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

.github/install-nix/action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ inputs:
1616
description: Substituters
1717
required: false
1818
default: ''
19+
nix-github-token:
20+
description: GitHub token to add as access-token in nix.conf
21+
default: ''
22+
required: false
1923

2024
runs:
2125
using: "composite"
@@ -25,6 +29,7 @@ runs:
2529
if: ${{ runner.environment == 'github-hosted' }}
2630
with:
2731
extra_nix_config: |
32+
${{ inputs.nix-github-token != '' && format('access-tokens = github.com={0}', inputs.nix-github-token) || '' }}
2833
accept-flake-config = true
2934
allow-import-from-derivation = true
3035
substituters = https://cache.nixos.org ${{inputs.substituters}}

.github/print-matrix/action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ inputs:
2424
pr-comment-github-token:
2525
description: GitHub token used to post the PR comment
2626
required: true
27+
nix-github-token:
28+
description: GitHub token to add as access-token in nix.conf
29+
default: ''
30+
required: false
2731

2832
outputs:
2933
matrix:
@@ -43,6 +47,7 @@ runs:
4347
cachix-auth-token: ${{ inputs.CACHIX_AUTH_TOKEN }}
4448
trusted-public-keys: ${{ inputs.TRUSTED_PUBLIC_KEYS }}
4549
substituters: ${{ inputs.SUBSTITUTERS }}
50+
nix-github-token: ${{ inputs.nix-github-token }}
4651

4752
- name: Print CI Matrix
4853
id: print-matrix

.github/workflows/ci.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ on:
99
type: 'boolean'
1010
default: false
1111
required: false
12+
secrets:
13+
nix-github-token:
14+
description: GitHub token to add as access-token in nix.conf
15+
required: false
1216

1317
# Allow this workflow to be triggered manually:
1418
workflow_dispatch:
@@ -57,6 +61,7 @@ jobs:
5761
cachix-auth-token: ${{ secrets.CACHIX_AUTH_TOKEN }}
5862
trusted-public-keys: ${{ vars.TRUSTED_PUBLIC_KEYS }}
5963
substituters: ${{ vars.SUBSTITUTERS }}
64+
nix-github-token: ${{ secrets.nix-github-token }}
6065

6166
- uses: actions/checkout@v4
6267

@@ -85,6 +90,7 @@ jobs:
8590
cachix-auth-token: ${{ secrets.CACHIX_AUTH_TOKEN }}
8691
trusted-public-keys: ${{ vars.TRUSTED_PUBLIC_KEYS }}
8792
substituters: ${{ vars.SUBSTITUTERS }}
93+
nix-github-token: ${{ secrets.nix-github-token }}
8894

8995
- uses: actions/checkout@v4
9096

@@ -162,6 +168,7 @@ jobs:
162168
substituters: ${{ vars.SUBSTITUTERS }}
163169
precalc_matrix: ${{ steps.matrix.outputs.fullMatrix }}
164170
pr-comment-github-token: ${{ secrets.GITHUB_TOKEN }}
171+
nix-github-token: ${{ secrets.nix-github-token }}
165172

166173
build:
167174
needs: slurp-matrix
@@ -214,6 +221,7 @@ jobs:
214221
substituters: ${{ vars.SUBSTITUTERS }}
215222
precalc_matrix: ${{ needs.slurp-matrix.outputs.fullMatrix }}
216223
pr-comment-github-token: ${{ secrets.GITHUB_TOKEN }}
224+
nix-github-token: ${{ secrets.nix-github-token }}
217225

218226
- run: exit 1
219227
if: >-

0 commit comments

Comments
 (0)