ci/github-script: allow running for single PR

Makes specific tests in the upstream repo easier to do.

Changed files
+16 -5
ci
github-script
run
+16 -5
ci/github-script/run
···
import { program } from 'commander'
import { getOctokit } from '@actions/github'
-
async function run(action, owner, repo) {
+
async function run(action, owner, repo, pull_number) {
const token = execSync('gh auth token', { encoding: 'utf-8' }).trim()
+
const github = getOctokit(token)
+
+
const payload = !pull_number ? {} : {
+
pull_request: (await github.rest.pulls.get({
+
owner,
+
repo,
+
pull_number,
+
})).data
+
}
+
const tmp = mkdtempSync(join(tmpdir(), 'github-script-'))
try {
process.env.GITHUB_WORKSPACE = tmp
process.chdir(tmp)
await action({
-
github: getOctokit(token),
+
github,
context: {
-
payload: {},
+
payload,
repo: {
owner,
repo,
···
.description('Manage labels on pull requests.')
.argument('<owner>', 'Owner of the GitHub repository to label (Example: NixOS)')
.argument('<repo>', 'Name of the GitHub repository to label (Example: nixpkgs)')
-
.action(async (owner, repo) => {
+
.argument('[pr]', 'Number of the Pull Request to label')
+
.action(async (owner, repo, pr) => {
const labels = (await import('./labels.js')).default
-
run(labels, owner, repo)
+
run(labels, owner, repo, pr)
})
await program.parse()