-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
27 lines (26 loc) · 871 Bytes
/
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
import fs from "fs"
import { glob } from "glob"
import YAML from "yamljs"
export default (pattern) =>
glob
.sync(pattern)
.map((path) => fs.readFileSync(path, "utf8"))
.map((content) => YAML.parse(content))
.filter((content) => Object.prototype.hasOwnProperty.call(content, "jobs"))
.map((yaml) => yaml.jobs)
.flatMap((jobs) => Object.values(jobs))
.flatMap((job) => job.steps)
.filter((step) => Object.prototype.hasOwnProperty.call(step, "uses"))
.map((step) => step.uses)
.filter((uses) => !uses.startsWith("actions/"))
.reduce((accumulator, uses) => {
if (
uses.split("@").length !== 2 ||
uses.split("@")[1].search(/[a-z0-9]{40}$/) === -1
) {
accumulator.push(
`${uses} should use a commit hash as a version identifier`,
)
}
return accumulator
}, [])