Skip to content

Commit

Permalink
fix: avoid the arg list too long error in bash environments
Browse files Browse the repository at this point in the history
  • Loading branch information
blaggacao committed Mar 31, 2023
1 parent 57baf7f commit 81092fc
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
6 changes: 5 additions & 1 deletion run/_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ function calc_uncached() {

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

echo "uncached=${uncached[*]}" >>"$GITHUB_OUTPUT"
echo "${uncached[*]}" > "$UNCACHED_FILE"

if [[ -n ${uncached[*]} ]]; then
echo "has_uncached=true" >>"$GITHUB_OUTPUT"
fi
}

#shellcheck disable=SC2068
Expand Down
4 changes: 1 addition & 3 deletions run/_cache.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ function upload() {

echo "::debug::Running $(basename $BASH_SOURCE):upload()"
echo "::debug::uploading$UNCACHED"
if [[ -n $NIX_KEY_PATH && $CACHE =~ ^s3:// ]]; then
if [[ $CACHE =~ \? ]]; then
CACHE="$CACHE&secret-key=$NIX_KEY_PATH"
Expand All @@ -17,7 +15,7 @@ function upload() {
fi
fi
echo "$UNCACHED" | xargs -- nix copy --from "$BUILDER" --to "$CACHE"
cat "$UNCACHED_FILE" | xargs -- nix copy --from "$BUILDER" --to "$CACHE"
}
echo "::group::🌲 Recycle work into cache ..."
Expand Down
2 changes: 1 addition & 1 deletion run/_run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function run() {
echo "::group::🏍️️ $action //$cell/$block/$target"
if [[ -z $BUILT ]]; then
if [[ -z $(head "$UNCACHED_FILE") ]]; then
# should be fetched, since we have already checked cache status in build step
nix-build "$drv" --no-out-link
elif [[ $BUILDER != auto ]]; then
Expand Down
7 changes: 4 additions & 3 deletions run/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,14 @@ runs:
JSON: ${{ inputs.discovery_json }}
OS: ${{ runner.os }}
SCRIPT: ${{ github.action_path }}/_build.sh
UNCACHED_FILE: ${{ runner.temp }}/uncached
run: ${{ github.action_path }}/build.sh
shell: bash

- name: ${{ fromJSON(inputs.discovery_json).action }} ${{ fromJSON(inputs.discovery_json).name }}
if: fromJSON(inputs.discovery_json).action != 'build'
env:
BUILT: ${{ steps.build.outputs.uncached }}
UNCACHED_FILE: ${{ runner.temp }}/uncached
BUILDER: ${{ inputs.builder_host }}
JSON: ${{ inputs.discovery_json }}
PRJ_ROOT: ${{ github.workspace }}
Expand All @@ -126,9 +127,9 @@ runs:
env:
CACHE: ${{ inputs.nix_cache }}
BUILDER: ${{ inputs.builder_host }}
UNCACHED: ${{ steps.build.outputs.uncached }}
UNCACHED_FILE: ${{ runner.temp }}/uncached
OS: ${{ runner.os }}
SCRIPT: ${{ github.action_path }}/_cache.sh
if: always() && env.CACHE != 'auto' && env.UNCACHED != '' && steps.build.conclusion == 'success'
if: always() && env.CACHE != 'auto' && steps.build.outputs.uncached == 'true' && steps.build.conclusion == 'success'
run: ${{ github.action_path }}/cache.sh
shell: bash

0 comments on commit 81092fc

Please sign in to comment.