-
Notifications
You must be signed in to change notification settings - Fork 254
Expand file tree
/
Copy pathpin-github-actions.js
More file actions
executable file
·39 lines (33 loc) · 1.11 KB
/
pin-github-actions.js
File metadata and controls
executable file
·39 lines (33 loc) · 1.11 KB
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
#! /usr/bin/env node
import glob from 'fast-glob'
import {fileURLToPath} from 'url'
import path from 'node:path'
import utils from 'util'
import {exec} from 'child_process'
export const execute = utils.promisify(exec)
const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)
const args = process.argv
if (args.length !== 3) {
console.log(
[
`Usage: bin/${path.basename(__filename)} <GITHUB_ACCESS_TOKEN>\n`,
'This script needs a Github access token to avoid hitting rate limits.',
'You can grab your existing one by running `dev github print-auth --password`.',
].join('\n'),
)
process.exit(1)
}
const githubAccessToken = args[2]
async function doIt() {
const githubYmls = glob.sync(`${__dirname}/../.github/{actions,workflows}/**/*.yml`)
const pinGithubAction = `${__dirname}/../node_modules/.bin/pin-github-action`
for (const githubYml of githubYmls) {
await execute(
`GH_ADMIN_TOKEN=${githubAccessToken} ${pinGithubAction} ${githubYml} --allow="actions/*" --allow-empty`,
)
process.stdout.write('.')
}
console.log(' Done!')
}
doIt()