generated from actions/javascript-action
-
Notifications
You must be signed in to change notification settings - Fork 19
/
actions.js
58 lines (45 loc) · 1.32 KB
/
actions.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
const utils = require("./utils");
const core = require("@actions/core");
async function deleteByTag(config, octokit) {
core.info(`🔎 search package version with tag ${config.tag}...`);
const packageVersion = await utils.findPackageVersionByTag(
octokit,
config.owner,
config.name,
config.tag
);
core.info(`🆔 package id is #${packageVersion.id}, delete it...`);
await utils.deletePackageVersion(
octokit,
config.owner,
config.name,
packageVersion.id
);
core.info(`✅ package #${packageVersion.id} deleted.`);
}
async function deleteUntaggedOrderGreaterThan(config, octokit) {
core.info(`🔎 find not latest ${config.untaggedKeepLatest} packages...`);
const pkgs = await utils.findPackageVersionsUntaggedOrderGreaterThan(
octokit,
config.owner,
config.name,
config.untaggedKeepLatest
);
core.startGroup(`🗑 delete ${pkgs.length} packages`);
for (const pkg of pkgs) {
try {
await utils.deletePackageVersion(
octokit,
config.owner,
config.name,
pkg.id
);
} catch (error) {
core.info(`⚠️ package #${pkg.id} not deleted: ${error.message}`);
continue;
}
core.info(`✅ package #${pkg.id} deleted.`);
}
core.endGroup();
}
module.exports = { deleteByTag, deleteUntaggedOrderGreaterThan };