Skip to content

Commit e0037f4

Browse files
committed
refactor(ci): extract nix eval into reusable workflow
1 parent b6ad602 commit e0037f4

File tree

3 files changed

+40
-16
lines changed

3 files changed

+40
-16
lines changed

.github/actions/nix-install-ephemeral/action.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@ runs:
1212
uses: aws-actions/configure-aws-credentials@v4
1313
if: ${{ inputs.push-to-cache == 'true' }}
1414
with:
15-
role-to-assume: ${{ secrets.DEV_AWS_ROLE }}
15+
role-to-assume: ${{ env.DEV_AWS_ROLE }}
1616
aws-region: "us-east-1"
1717
output-credentials: true
18-
role-duration-seconds: 18000
18+
role-duration-seconds: 7200
1919
- name: Setup AWS credentials for Nix
2020
if: ${{ inputs.push-to-cache == 'true' }}
21+
shell: bash
2122
run: |
2223
sudo -H aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID
2324
sudo -H aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY
@@ -32,7 +33,7 @@ runs:
3233
EOF
3334
sudo chmod +x /etc/nix/upload-to-cache.sh
3435
env:
35-
NIX_SIGN_SECRET_KEY: ${{ secrets.NIX_SIGN_SECRET_KEY }}
36+
NIX_SIGN_SECRET_KEY: ${{ env.NIX_SIGN_SECRET_KEY }}
3637
- name: Install nix
3738
uses: cachix/install-nix-action@v31
3839
with:

.github/workflows/nix-build.yml

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,10 @@ permissions:
1616

1717
jobs:
1818
nix-eval:
19-
runs-on: blacksmith-32vcpu-ubuntu-2404
20-
outputs:
21-
matrix: ${{ steps.set-matrix.outputs.matrix }}
22-
steps:
23-
- name: Checkout Repo
24-
uses: actions/checkout@v4
25-
- name: Install nix
26-
uses: ./.github/actions/nix-install-ephemeral
27-
- id: set-matrix
28-
name: Generate Nix Matrix
29-
run: |
30-
set -Eeu
31-
echo matrix="$(nix shell github:nix-community/nix-eval-jobs --command scripts/github-matrix.py checks legacyPackages)" >> "$GITHUB_OUTPUT"
19+
uses: ./.github/workflows/nix-eval.yml
20+
secrets:
21+
DEV_AWS_ROLE: ${{ secrets.DEV_AWS_ROLE }}
22+
NIX_SIGN_SECRET_KEY: ${{ secrets.NIX_SIGN_SECRET_KEY }}
3223

3324
nix-build-aarch64-linux:
3425
name: ${{ matrix.name }} (aarch64-linux)

.github/workflows/nix-eval.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Nix Eval
2+
3+
on:
4+
workflow_call:
5+
outputs:
6+
matrix:
7+
description: 'Generated build matrix'
8+
value: ${{ jobs.eval.outputs.matrix }}
9+
secrets:
10+
DEV_AWS_ROLE:
11+
required: false
12+
NIX_SIGN_SECRET_KEY:
13+
required: false
14+
15+
jobs:
16+
eval:
17+
runs-on: blacksmith-32vcpu-ubuntu-2404
18+
outputs:
19+
matrix: ${{ steps.set-matrix.outputs.matrix }}
20+
steps:
21+
- name: Checkout Repo
22+
uses: actions/checkout@v4
23+
- name: Install nix
24+
uses: ./.github/actions/nix-install-ephemeral
25+
env:
26+
DEV_AWS_ROLE: ${{ secrets.DEV_AWS_ROLE }}
27+
NIX_SIGN_SECRET_KEY: ${{ secrets.NIX_SIGN_SECRET_KEY }}
28+
- id: set-matrix
29+
name: Generate Nix Matrix
30+
run: |
31+
set -Eeu
32+
echo matrix="$(nix shell github:nix-community/nix-eval-jobs --command scripts/github-matrix.py checks legacyPackages)" >> "$GITHUB_OUTPUT"

0 commit comments

Comments
 (0)