mirror of
https://github.com/rexlManu/pterodactyl-upload-action.git
synced 2025-02-03 13:36:41 -05:00
feat: glob pattern for source inputs
This commit is contained in:
parent
f65b7500c8
commit
b39382b52d
4 changed files with 70 additions and 8 deletions
|
@ -33,6 +33,9 @@ inputs:
|
|||
description: "Decompress archive file after upload in target"
|
||||
required: false
|
||||
default: false
|
||||
follow-symbolic-links:
|
||||
description: "Indicates whether to follow symbolic links"
|
||||
default: true
|
||||
runs:
|
||||
using: "node16"
|
||||
main: "dist/index.js"
|
||||
|
|
40
package-lock.json
generated
40
package-lock.json
generated
|
@ -11,6 +11,7 @@
|
|||
"dependencies": {
|
||||
"@actions/core": "^1.10.0",
|
||||
"@actions/github": "^5.1.1",
|
||||
"@actions/glob": "^0.4.0",
|
||||
"axios": "^1.4.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
@ -37,6 +38,15 @@
|
|||
"@octokit/plugin-rest-endpoint-methods": "^5.13.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@actions/glob": {
|
||||
"version": "0.4.0",
|
||||
"resolved": "https://registry.npmjs.org/@actions/glob/-/glob-0.4.0.tgz",
|
||||
"integrity": "sha512-+eKIGFhsFa4EBwaf/GMyzCdWrXWymGXfFmZU3FHQvYS8mPcHtTtZONbkcqqUMzw9mJ/pImEBFET1JNifhqGsAQ==",
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.9.1",
|
||||
"minimatch": "^3.0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/@actions/http-client": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.1.0.tgz",
|
||||
|
@ -170,11 +180,25 @@
|
|||
"proxy-from-env": "^1.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/balanced-match": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
|
||||
"integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw=="
|
||||
},
|
||||
"node_modules/before-after-hook": {
|
||||
"version": "2.2.3",
|
||||
"resolved": "https://registry.npmjs.org/before-after-hook/-/before-after-hook-2.2.3.tgz",
|
||||
"integrity": "sha512-NzUnlZexiaH/46WDhANlyR2bXRopNg4F/zuSA3OpZnllCUgRaOF2znDioDWrmbNVsuZk6l9pMquQB38cfBZwkQ=="
|
||||
},
|
||||
"node_modules/brace-expansion": {
|
||||
"version": "1.1.11",
|
||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
|
||||
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
|
||||
"dependencies": {
|
||||
"balanced-match": "^1.0.0",
|
||||
"concat-map": "0.0.1"
|
||||
}
|
||||
},
|
||||
"node_modules/combined-stream": {
|
||||
"version": "1.0.8",
|
||||
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
|
||||
|
@ -186,6 +210,11 @@
|
|||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/concat-map": {
|
||||
"version": "0.0.1",
|
||||
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
|
||||
"integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg=="
|
||||
},
|
||||
"node_modules/delayed-stream": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
|
||||
|
@ -258,6 +287,17 @@
|
|||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/minimatch": {
|
||||
"version": "3.1.2",
|
||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz",
|
||||
"integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==",
|
||||
"dependencies": {
|
||||
"brace-expansion": "^1.1.7"
|
||||
},
|
||||
"engines": {
|
||||
"node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/node-fetch": {
|
||||
"version": "2.6.11",
|
||||
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.11.tgz",
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
"dependencies": {
|
||||
"@actions/core": "^1.10.0",
|
||||
"@actions/github": "^5.1.1",
|
||||
"@actions/glob": "^0.4.0",
|
||||
"axios": "^1.4.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
|
20
src/index.js
20
src/index.js
|
@ -2,6 +2,7 @@ const core = require("@actions/core");
|
|||
const axios = require("axios").default;
|
||||
const fs = require("fs").promises;
|
||||
const path = require("path");
|
||||
const glob = require("@actions/glob");
|
||||
|
||||
axios.defaults.headers.common.Accept = "application/json";
|
||||
|
||||
|
@ -19,8 +20,17 @@ async function main() {
|
|||
decompressTarget,
|
||||
} = settings;
|
||||
|
||||
for (const serverId of serverIds) {
|
||||
let fileSourcePaths = [];
|
||||
for (const source of sourceListPath) {
|
||||
const globber = await glob.create(source, {
|
||||
followSymbolicLinks: settings.followSymbolicLinks,
|
||||
});
|
||||
const files = await globber.glob();
|
||||
fileSourcePaths = [...fileSourcePaths, ...files];
|
||||
}
|
||||
|
||||
for (const serverId of serverIds) {
|
||||
for (const source of fileSourcePaths) {
|
||||
await validateSourceFile(source);
|
||||
const targetFile = getTargetFile(targetPath, source);
|
||||
const buffer = await fs.readFile(source);
|
||||
|
@ -35,6 +45,11 @@ async function main() {
|
|||
|
||||
for (const element of targets) {
|
||||
const { source, target } = element;
|
||||
const globber = await glob.create(source, {
|
||||
followSymbolicLinks: settings.followSymbolicLinks,
|
||||
});
|
||||
const paths = await globber.glob();
|
||||
for (const source of paths) {
|
||||
await validateSourceFile(source);
|
||||
const targetFile = getTargetFile(target, source);
|
||||
const buffer = await fs.readFile(source);
|
||||
|
@ -46,6 +61,7 @@ async function main() {
|
|||
await deleteFile(serverId, targetFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (restart) await restartServer(serverId);
|
||||
}
|
||||
|
@ -62,6 +78,7 @@ async function getSettings() {
|
|||
const restart = getInput("restart") == "true";
|
||||
const proxy = getInput("proxy");
|
||||
const decompressTarget = getInput("decompress-target") == "true";
|
||||
const followSymbolicLinks = getInput("follow-symbolic-links") == "true";
|
||||
|
||||
let sourcePath = getInput("source");
|
||||
let sourceListPath = getMultilineInput("sources");
|
||||
|
@ -125,6 +142,7 @@ async function getSettings() {
|
|||
serverIds,
|
||||
targets,
|
||||
decompressTarget,
|
||||
followSymbolicLinks,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue