From 97d410394634b8bb5963faba4dec6bfda6f67661 Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Sun, 13 Jul 2025 18:58:35 +0200 Subject: [PATCH] ci/github-script: allow running for single PR Makes specific tests in the upstream repo easier to do. --- ci/github-script/run | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/ci/github-script/run b/ci/github-script/run index 1b670a8b2875..8241da429eeb 100755 --- a/ci/github-script/run +++ b/ci/github-script/run @@ -6,18 +6,28 @@ import { join } from 'node:path' 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, @@ -47,9 +57,10 @@ program .description('Manage labels on pull requests.') .argument('', 'Owner of the GitHub repository to label (Example: NixOS)') .argument('', '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()