···
import { program } from 'commander'
import { getOctokit } from '@actions/github'
-
async function run(action, owner, repo) {
const token = execSync('gh auth token', { encoding: 'utf-8' }).trim()
const tmp = mkdtempSync(join(tmpdir(), 'github-script-'))
process.env.GITHUB_WORKSPACE = tmp
-
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)')
-
.action(async (owner, repo) => {
const labels = (await import('./labels.js')).default
-
run(labels, owner, repo)
···
import { program } from 'commander'
import { getOctokit } from '@actions/github'
+
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({
const tmp = mkdtempSync(join(tmpdir(), 'github-script-'))
process.env.GITHUB_WORKSPACE = tmp
···
.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)')
+
.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, pr)