ci/github-script: move from ci/labels
This just moves things around to use less specific naming - `labels` is only *one* script that can potentially be run locally while still being written in github-script. Later, we can add more.
This commit is contained in:
45
ci/github-script/run.js
Executable file
45
ci/github-script/run.js
Executable file
@@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env node
|
||||
import { execSync } from 'node:child_process'
|
||||
import { mkdtempSync, rmSync } from 'node:fs'
|
||||
import { tmpdir } from 'node:os'
|
||||
import { join } from 'node:path'
|
||||
import { getOctokit } from '@actions/github'
|
||||
import labels from './labels.cjs'
|
||||
|
||||
if (process.argv.length !== 4)
|
||||
throw new Error('Call this with exactly three arguments: ./run OWNER REPO')
|
||||
const [, , owner, repo] = process.argv
|
||||
|
||||
const token = execSync('gh auth token', { encoding: 'utf-8' }).trim()
|
||||
|
||||
const tmp = mkdtempSync(join(tmpdir(), 'labels-'))
|
||||
try {
|
||||
process.env.GITHUB_WORKSPACE = tmp
|
||||
process.chdir(tmp)
|
||||
|
||||
await labels({
|
||||
github: getOctokit(token),
|
||||
context: {
|
||||
payload: {},
|
||||
repo: {
|
||||
owner,
|
||||
repo,
|
||||
},
|
||||
},
|
||||
core: {
|
||||
getInput() {
|
||||
return token
|
||||
},
|
||||
error: console.error,
|
||||
info: console.log,
|
||||
notice: console.log,
|
||||
setFailed(msg) {
|
||||
console.error(msg)
|
||||
process.exitCode = 1
|
||||
},
|
||||
},
|
||||
dry: true,
|
||||
})
|
||||
} finally {
|
||||
rmSync(tmp, { recursive: true })
|
||||
}
|
||||
Reference in New Issue
Block a user