Allow user to select paths to where to store files

This commit is contained in:
Wroclaw 2024-02-21 17:15:21 +01:00
parent fb0022d247
commit b7ff0eaea5
5 changed files with 19 additions and 7 deletions

View file

@ -8,6 +8,9 @@ inputs:
webhook:
description: "Discord webhook url to use"
required: true
outputFileLocation:
description: "Where to write a file containing current message ids for this run"
default: "./messageIDs.txt"
storageMethod:
description: |-
Method of storing old message ids to delete
@ -16,6 +19,8 @@ inputs:
- git - stores ids in git repository
default: none
required: true
storegeGitFileLocation:
description: "Where in git repository file should be saved"
runs:
using: node20

8
dist/index.js vendored
View file

@ -129103,7 +129103,7 @@ async function main() {
}
const messageIDsConcatenated = messageIDs.join("\n");
core.info(`Messages sent! IDs:\n${messageIDsConcatenated}`);
await promises_1.default.writeFile("./messageIDs.txt", messageIDsConcatenated);
await promises_1.default.writeFile(core.getInput("outputFileLocation"), messageIDsConcatenated);
await Promise.all([
storage_1.default.pushMessageIDs(),
presentMessageIds.map(v => client.deleteMessage(v)),
@ -129169,7 +129169,7 @@ async function getMessageIDs() {
case "none":
return [];
case "git":
return promises_1.default.readFile("./messageIDs.txt")
return promises_1.default.readFile(core.getInput("storageGitFileLocation"))
.then(v => v.toString().trim().split("\n"))
.catch(e => {
core.warning("Couldn't read messageIDs");
@ -129186,9 +129186,11 @@ async function pushMessageIDs() {
const method = getStorageMethod();
switch (method) {
case "git":
const gitFileLocation = core.getInput("storageGitFileLocation", { required: true });
await promises_1.default.copyFile(core.getInput("outputFileLocation"), gitFileLocation);
await exec("git config --global user.name \"Actions\"");
await exec("git config --global user.email \"noreply@users.noreply.github.com\"");
await exec("git add ./messageIDs.txt");
await exec(`git add ${gitFileLocation}`);
await (0, exec_1.exec)("git", ["commit", "-m", "Update stored messageIDs"]);
await exec("git push");
return true;

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View file

@ -98,7 +98,7 @@ async function main() {
const messageIDsConcatenated = messageIDs.join("\n");
core.info(`Messages sent! IDs:\n${messageIDsConcatenated}`);
await fs.writeFile("./messageIDs.txt", messageIDsConcatenated);
await fs.writeFile(core.getInput("outputFileLocation"), messageIDsConcatenated);
await Promise.all([
storage.pushMessageIDs(),

View file

@ -21,7 +21,7 @@ export async function getMessageIDs(): Promise<string[]> {
case "none":
return [];
case "git":
return fs.readFile("./messageIDs.txt")
return fs.readFile(core.getInput("storageGitFileLocation"))
.then(v => v.toString().trim().split("\n"))
.catch(e => {
core.warning("Couldn't read messageIDs");
@ -38,9 +38,14 @@ export async function pushMessageIDs() {
const method = getStorageMethod();
switch (method) {
case "git":
const gitFileLocation = core.getInput("storageGitFileLocation", { required: true });
await fs.copyFile(
core.getInput("outputFileLocation"),
gitFileLocation
);
await exec("git config --global user.name \"Actions\"")
await exec("git config --global user.email \"noreply@users.noreply.github.com\"")
await exec("git add ./messageIDs.txt")
await exec(`git add ${gitFileLocation}`);
await _exec("git", ["commit", "-m", "Update stored messageIDs"])
await exec("git push");
return true;