From e78c87fc0e32a315c66c7e756caf798b2adaeb19 Mon Sep 17 00:00:00 2001 From: Ryan Cao <70191398+ryanccn@users.noreply.github.com> Date: Fri, 4 Aug 2023 20:40:01 +0800 Subject: [PATCH] fix: split up added paths to avoid argument limit --- package.json | 1 + pnpm-lock.yaml | 7 +++++++ src/stages/push.ts | 7 ++++++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 0c6a11f..52ec843 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "dependencies": { "@actions/core": "^1.10.0", "@actions/exec": "^1.1.1", + "just-split": "^3.2.0", "ofetch": "^1.1.1" }, "devDependencies": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2a2e02b..6c5fd51 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -11,6 +11,9 @@ dependencies: '@actions/exec': specifier: ^1.1.1 version: 1.1.1 + just-split: + specifier: ^3.2.0 + version: 3.2.0 ofetch: specifier: ^1.1.1 version: 1.1.1 @@ -290,6 +293,10 @@ packages: '@esbuild/win32-x64': 0.18.14 dev: true + /just-split@3.2.0: + resolution: {integrity: sha512-hh57dN5koTBkmg3T6gBFISVVaW5bgZ6Ct1W5KODD5M7hQJKqGzTKkfMwOil8MBxyztLQEjh/v6UGXE8cP5tnqQ==} + dev: false + /node-fetch-native@1.2.0: resolution: {integrity: sha512-5IAMBTl9p6PaAjYCnMv5FmqIF6GcZnawAVnzaCG0rX2aYZJ4CxEkZNtVPuTRug7fL7wyM5BQYTlAzcyMPi6oTQ==} dev: false diff --git a/src/stages/push.ts b/src/stages/push.ts index 41e940c..f911bb5 100644 --- a/src/stages/push.ts +++ b/src/stages/push.ts @@ -1,5 +1,7 @@ import * as core from "@actions/core"; import { exec } from "@actions/exec"; + +import splitArray from "just-split"; import { getStorePaths } from "../utils"; export const push = async () => { @@ -21,7 +23,10 @@ export const push = async () => { (p) => !p.endsWith(".drv") && !p.endsWith(".drv.chroot") && !p.endsWith(".check") && !p.endsWith(".lock"), ); - await exec("attic", ["push", cache, ...addedPaths]); + const splitAddedPaths = splitArray(addedPaths, 25); + for (const addedPaths of splitAddedPaths) { + await exec("attic", ["push", cache, ...addedPaths]); + } } } catch (e) { core.setFailed(`Action failed with error: ${e}`);