fix: split up added paths to avoid argument limit

This commit is contained in:
Ryan Cao 2023-08-04 20:40:01 +08:00
parent 7af24dd783
commit e78c87fc0e
No known key found for this signature in database
3 changed files with 14 additions and 1 deletions

View file

@ -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": {

View file

@ -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

View file

@ -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,8 +23,11 @@ export const push = async () => {
(p) => !p.endsWith(".drv") && !p.endsWith(".drv.chroot") && !p.endsWith(".check") && !p.endsWith(".lock"),
);
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}`);
}