Allow user to select paths to where to store files
This commit is contained in:
parent
fb0022d247
commit
b7ff0eaea5
5 changed files with 19 additions and 7 deletions
|
@ -8,6 +8,9 @@ inputs:
|
||||||
webhook:
|
webhook:
|
||||||
description: "Discord webhook url to use"
|
description: "Discord webhook url to use"
|
||||||
required: true
|
required: true
|
||||||
|
outputFileLocation:
|
||||||
|
description: "Where to write a file containing current message ids for this run"
|
||||||
|
default: "./messageIDs.txt"
|
||||||
storageMethod:
|
storageMethod:
|
||||||
description: |-
|
description: |-
|
||||||
Method of storing old message ids to delete
|
Method of storing old message ids to delete
|
||||||
|
@ -16,6 +19,8 @@ inputs:
|
||||||
- git - stores ids in git repository
|
- git - stores ids in git repository
|
||||||
default: none
|
default: none
|
||||||
required: true
|
required: true
|
||||||
|
storegeGitFileLocation:
|
||||||
|
description: "Where in git repository file should be saved"
|
||||||
|
|
||||||
runs:
|
runs:
|
||||||
using: node20
|
using: node20
|
||||||
|
|
8
dist/index.js
vendored
8
dist/index.js
vendored
|
@ -129103,7 +129103,7 @@ async function main() {
|
||||||
}
|
}
|
||||||
const messageIDsConcatenated = messageIDs.join("\n");
|
const messageIDsConcatenated = messageIDs.join("\n");
|
||||||
core.info(`Messages sent! IDs:\n${messageIDsConcatenated}`);
|
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([
|
await Promise.all([
|
||||||
storage_1.default.pushMessageIDs(),
|
storage_1.default.pushMessageIDs(),
|
||||||
presentMessageIds.map(v => client.deleteMessage(v)),
|
presentMessageIds.map(v => client.deleteMessage(v)),
|
||||||
|
@ -129169,7 +129169,7 @@ async function getMessageIDs() {
|
||||||
case "none":
|
case "none":
|
||||||
return [];
|
return [];
|
||||||
case "git":
|
case "git":
|
||||||
return promises_1.default.readFile("./messageIDs.txt")
|
return promises_1.default.readFile(core.getInput("storageGitFileLocation"))
|
||||||
.then(v => v.toString().trim().split("\n"))
|
.then(v => v.toString().trim().split("\n"))
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
core.warning("Couldn't read messageIDs");
|
core.warning("Couldn't read messageIDs");
|
||||||
|
@ -129186,9 +129186,11 @@ async function pushMessageIDs() {
|
||||||
const method = getStorageMethod();
|
const method = getStorageMethod();
|
||||||
switch (method) {
|
switch (method) {
|
||||||
case "git":
|
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.name \"Actions\"");
|
||||||
await exec("git config --global user.email \"noreply@users.noreply.github.com\"");
|
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 (0, exec_1.exec)("git", ["commit", "-m", "Update stored messageIDs"]);
|
||||||
await exec("git push");
|
await exec("git push");
|
||||||
return true;
|
return true;
|
||||||
|
|
2
dist/index.js.map
vendored
2
dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
|
@ -98,7 +98,7 @@ async function main() {
|
||||||
|
|
||||||
const messageIDsConcatenated = messageIDs.join("\n");
|
const messageIDsConcatenated = messageIDs.join("\n");
|
||||||
core.info(`Messages sent! IDs:\n${messageIDsConcatenated}`);
|
core.info(`Messages sent! IDs:\n${messageIDsConcatenated}`);
|
||||||
await fs.writeFile("./messageIDs.txt", messageIDsConcatenated);
|
await fs.writeFile(core.getInput("outputFileLocation"), messageIDsConcatenated);
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
storage.pushMessageIDs(),
|
storage.pushMessageIDs(),
|
||||||
|
|
|
@ -21,7 +21,7 @@ export async function getMessageIDs(): Promise<string[]> {
|
||||||
case "none":
|
case "none":
|
||||||
return [];
|
return [];
|
||||||
case "git":
|
case "git":
|
||||||
return fs.readFile("./messageIDs.txt")
|
return fs.readFile(core.getInput("storageGitFileLocation"))
|
||||||
.then(v => v.toString().trim().split("\n"))
|
.then(v => v.toString().trim().split("\n"))
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
core.warning("Couldn't read messageIDs");
|
core.warning("Couldn't read messageIDs");
|
||||||
|
@ -38,9 +38,14 @@ export async function pushMessageIDs() {
|
||||||
const method = getStorageMethod();
|
const method = getStorageMethod();
|
||||||
switch (method) {
|
switch (method) {
|
||||||
case "git":
|
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.name \"Actions\"")
|
||||||
await exec("git config --global user.email \"noreply@users.noreply.github.com\"")
|
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", ["commit", "-m", "Update stored messageIDs"])
|
||||||
await exec("git push");
|
await exec("git push");
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in a new issue