mirror of
https://github.com/rexlManu/pterodactyl-upload-action.git
synced 2025-02-03 13:36:41 -05:00
Added decompression feature
This commit is contained in:
parent
2d3597bc3d
commit
da215291f5
1 changed files with 20 additions and 2 deletions
22
src/index.js
22
src/index.js
|
@ -10,8 +10,8 @@ async function main() {
|
|||
const settings = await getSettings();
|
||||
configureAxios(settings.panelHost, settings.apiKey, settings.proxy);
|
||||
|
||||
const { serverIds, sourceListPath, targetPath, restart, targets } =
|
||||
settings;
|
||||
const { serverIds, sourceListPath, targetPath, restart, targets, decompress } =
|
||||
settings;
|
||||
|
||||
for (const serverId of serverIds) {
|
||||
for (const source of sourceListPath) {
|
||||
|
@ -20,7 +20,12 @@ async function main() {
|
|||
const buffer = await fs.readFile(source);
|
||||
|
||||
await uploadFile(serverId, targetFile, buffer);
|
||||
|
||||
if (decompress && decompress === source) {
|
||||
await decompressFile(serverId, targetFile);
|
||||
}
|
||||
}
|
||||
|
||||
for (const element of targets) {
|
||||
const { source, target } = element;
|
||||
await validateSourceFile(source);
|
||||
|
@ -28,6 +33,10 @@ async function main() {
|
|||
const buffer = await fs.readFile(source);
|
||||
|
||||
await uploadFile(serverId, targetFile, buffer);
|
||||
|
||||
if (decompress && decompress === source) {
|
||||
await decompressFile(serverId, targetFile);
|
||||
}
|
||||
}
|
||||
|
||||
if (restart) await restartServer(serverId);
|
||||
|
@ -44,6 +53,7 @@ async function getSettings() {
|
|||
const apiKey = getInput("api-key", { required: true });
|
||||
const restart = getInput("restart") == "true";
|
||||
const proxy = getInput("proxy");
|
||||
const decompress = getInput("decompress");
|
||||
|
||||
let sourcePath = getInput("source");
|
||||
let sourceListPath = getMultilineInput("sources");
|
||||
|
@ -106,6 +116,7 @@ async function getSettings() {
|
|||
targetPath,
|
||||
serverIds,
|
||||
targets,
|
||||
decompress,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -163,6 +174,13 @@ async function restartServer(serverId) {
|
|||
});
|
||||
}
|
||||
|
||||
async function decompressFile(serverId, targetFile) {
|
||||
await axios.post(`/api/client/servers/${serverId}/files/decompress`, {
|
||||
root: "/",
|
||||
file: targetFile,
|
||||
});
|
||||
}
|
||||
|
||||
function getInput(name, options = { required: false }) {
|
||||
return core.getInput(name, { ...options, trimWhitespace: true });
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue