···
import { program } from 'commander'
import { getOctokit } from '@actions/github'
9
-
async function run(action, owner, repo) {
9
+
async function run(action, owner, repo, pull_number) {
const token = execSync('gh auth token', { encoding: 'utf-8' }).trim()
12
+
const github = getOctokit(token)
14
+
const payload = !pull_number ? {} : {
15
+
pull_request: (await github.rest.pulls.get({
const tmp = mkdtempSync(join(tmpdir(), 'github-script-'))
process.env.GITHUB_WORKSPACE = tmp
18
-
github: getOctokit(token),
···
.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)')
50
-
.action(async (owner, repo) => {
60
+
.argument('[pr]', 'Number of the Pull Request to label')
61
+
.action(async (owner, repo, pr) => {
const labels = (await import('./labels.js')).default
52
-
run(labels, owner, repo)
63
+
run(labels, owner, repo, pr)