-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathindex.js
48 lines (40 loc) · 1.17 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import YAML from "yaml";
import extractActions from "./extractActions.js";
import replaceActions from "./replaceActions.js";
import findRefOnGithub from "./findRefOnGithub.js";
import checkAllowedRepos from "./checkAllowedRepos.js";
import isSha from "./isSha.js";
export default async function (
input,
allowed,
ignoreShas,
allowEmpty,
debug,
comment,
) {
allowed = allowed || [];
ignoreShas = ignoreShas || false;
// Parse the workflow file
let workflow = YAML.parseDocument(input);
// Extract list of actions
let actions = extractActions(workflow, allowEmpty, comment, debug);
for (let i in actions) {
// Should this action be updated?
const action = `${actions[i].owner}/${actions[i].repo}`;
if (checkAllowedRepos(action, allowed, debug)) {
continue;
}
if (ignoreShas && isSha(actions[i])) {
continue;
}
// Look up those actions on Github
const newVersion = await findRefOnGithub(actions[i], debug);
actions[i].newVersion = newVersion;
// Rewrite each action, replacing the uses block with a specific SHA
input = replaceActions(input, actions[i], comment);
}
return {
input,
actions,
};
}