-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
34 lines (32 loc) · 1.09 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
const { getInput, setFailed, info } = require("@actions/core");
const { context } = require("@actions/github");
const deleteVersions = require("./delete-versions");
async function run() {
try {
const inputs = {
owner: getInput("owner") || context.repo.owner,
repo: getInput("repo") || context.repo.repo,
keepCnt: Number(getInput("keepCnt")), // getInput converts ALL values to string!
dryRun: getInput("dryRun"),
token: getInput("token"),
};
info("Input values:");
Object.entries(inputs).map((v) => info(v[0] + ": " + v[1]));
if (inputs.dryRun === "false") inputs.dryRun = false; // getInput converts ALL values to string!
if (inputs.dryRun) {
info(
"Dry run is NOT deleting packages, list below is what would be deleted, dryRun: " +
Number(inputs.dryRun)
);
}
const deleted = await deleteVersions(inputs);
deleted.forEach((package) => {
package.versions.forEach((v) => {
info(`Deleted ${package.name} version ${v.version}`);
});
});
} catch (error) {
setFailed(error.message);
}
}
run();