Repository navigation
Expand file tree
/
Copy pathaction.yml
More file actions
78 lines (70 loc) · 2.69 KB
/
Copy pathaction.yml
File metadata and controls
78 lines (70 loc) · 2.69 KB
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
name: Nix S3 cache
description: Enable Nix build path recording and upload recorded paths to an S3 binary cache.
inputs:
operation:
description: "Operation to run: enable-recorder or upload."
required: true
aws-role-to-assume:
description: AWS IAM role to assume before uploading Nix paths.
required: false
aws-region:
description: AWS region for the Nix cache upload role.
required: false
default: us-east-1
role-duration-seconds:
description: AWS role duration for the Nix cache upload role.
required: false
default: "21600"
cache-private-key:
description: Private signing key for the Nix binary cache.
required: false
cache-s3-store-url:
description: Nix S3 store URL used as the nix copy destination.
required: false
runs:
using: composite
steps:
- name: Validate operation
shell: bash
env:
OPERATION: ${{ inputs.operation }}
run: |
set -euo pipefail
case "$OPERATION" in
enable-recorder|upload) ;;
*)
echo "Unsupported operation: $OPERATION" >&2
echo "Expected one of: enable-recorder, upload" >&2
exit 1
;;
esac
- name: Enable Nix remote cache path recorder
if: ${{ inputs.operation == 'enable-recorder' }}
shell: bash
run: bash "$GITHUB_ACTION_PATH/enable-recorder.sh"
- name: Configure AWS credentials for Nix cache upload
id: nix-cache-credentials
if: ${{ inputs.operation == 'upload' }}
uses: aws-actions/configure-aws-credentials@v6
with:
role-to-assume: ${{ inputs.aws-role-to-assume }}
aws-region: ${{ inputs.aws-region }}
role-duration-seconds: ${{ inputs.role-duration-seconds }}
output-env-credentials: false
output-credentials: true
- name: Upload built Nix paths to S3 cache
if: ${{ inputs.operation == 'upload' }}
shell: bash
env:
AWS_ACCESS_KEY_ID: ${{ steps.nix-cache-credentials.outputs.aws-access-key-id || env.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ steps.nix-cache-credentials.outputs.aws-secret-access-key || env.AWS_SECRET_ACCESS_KEY }}
AWS_SESSION_TOKEN: ${{ steps.nix-cache-credentials.outputs.aws-session-token || env.AWS_SESSION_TOKEN }}
AWS_REGION: ${{ inputs.aws-region }}
AWS_DEFAULT_REGION: ${{ inputs.aws-region }}
NIX_CACHE_PRIVATE_KEY: ${{ inputs.cache-private-key }}
NIX_CACHE_S3_STORE_URL: ${{ inputs.cache-s3-store-url }}
run: bash "$GITHUB_ACTION_PATH/upload.sh"
- name: Clean up Nix S3 cache files
if: ${{ always() && inputs.operation == 'upload' }}
shell: bash
run: bash "$GITHUB_ACTION_PATH/cleanup.sh"