Skip to content

Commit 81092fc

Browse files
committed
fix: avoid the arg list too long error in bash environments
1 parent 57baf7f commit 81092fc

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

run/_build.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ function calc_uncached() {
2525

2626
echo "::debug::uncached paths: ${uncached[*]}"
2727

28-
echo "uncached=${uncached[*]}" >>"$GITHUB_OUTPUT"
28+
echo "${uncached[*]}" > "$UNCACHED_FILE"
29+
30+
if [[ -n ${uncached[*]} ]]; then
31+
echo "has_uncached=true" >>"$GITHUB_OUTPUT"
32+
fi
2933
}
3034

3135
#shellcheck disable=SC2068

run/_cache.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ function upload() {
77

88
echo "::debug::Running $(basename $BASH_SOURCE):upload()"
99
10-
echo "::debug::uploading$UNCACHED"
11-
1210
if [[ -n $NIX_KEY_PATH && $CACHE =~ ^s3:// ]]; then
1311
if [[ $CACHE =~ \? ]]; then
1412
CACHE="$CACHE&secret-key=$NIX_KEY_PATH"
@@ -17,7 +15,7 @@ function upload() {
1715
fi
1816
fi
1917
20-
echo "$UNCACHED" | xargs -- nix copy --from "$BUILDER" --to "$CACHE"
18+
cat "$UNCACHED_FILE" | xargs -- nix copy --from "$BUILDER" --to "$CACHE"
2119
}
2220
2321
echo "::group::🌲 Recycle work into cache ..."

run/_run.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function run() {
1414
1515
echo "::group::🏍️️ $action //$cell/$block/$target"
1616
17-
if [[ -z $BUILT ]]; then
17+
if [[ -z $(head "$UNCACHED_FILE") ]]; then
1818
# should be fetched, since we have already checked cache status in build step
1919
nix-build "$drv" --no-out-link
2020
elif [[ $BUILDER != auto ]]; then

run/action.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,14 @@ runs:
106106
JSON: ${{ inputs.discovery_json }}
107107
OS: ${{ runner.os }}
108108
SCRIPT: ${{ github.action_path }}/_build.sh
109+
UNCACHED_FILE: ${{ runner.temp }}/uncached
109110
run: ${{ github.action_path }}/build.sh
110111
shell: bash
111112

112113
- name: ${{ fromJSON(inputs.discovery_json).action }} ${{ fromJSON(inputs.discovery_json).name }}
113114
if: fromJSON(inputs.discovery_json).action != 'build'
114115
env:
115-
BUILT: ${{ steps.build.outputs.uncached }}
116+
UNCACHED_FILE: ${{ runner.temp }}/uncached
116117
BUILDER: ${{ inputs.builder_host }}
117118
JSON: ${{ inputs.discovery_json }}
118119
PRJ_ROOT: ${{ github.workspace }}
@@ -126,9 +127,9 @@ runs:
126127
env:
127128
CACHE: ${{ inputs.nix_cache }}
128129
BUILDER: ${{ inputs.builder_host }}
129-
UNCACHED: ${{ steps.build.outputs.uncached }}
130+
UNCACHED_FILE: ${{ runner.temp }}/uncached
130131
OS: ${{ runner.os }}
131132
SCRIPT: ${{ github.action_path }}/_cache.sh
132-
if: always() && env.CACHE != 'auto' && env.UNCACHED != '' && steps.build.conclusion == 'success'
133+
if: always() && env.CACHE != 'auto' && steps.build.outputs.uncached == 'true' && steps.build.conclusion == 'success'
133134
run: ${{ github.action_path }}/cache.sh
134135
shell: bash

0 commit comments

Comments
 (0)