From 07a1ff68be70e37e488f938816aa93ae6724cae3 Mon Sep 17 00:00:00 2001 From: Anthony Stirling <77850077+Frooodle@users.noreply.github.com> Date: Tue, 5 May 2026 17:45:32 +0100 Subject: [PATCH] Add nightly job to label Gittensor-tracked PRs --- .github/labels.yml | 3 ++ .github/workflows/nightly.yml | 63 +++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) diff --git a/.github/labels.yml b/.github/labels.yml index a6888e7795..0b878f577f 100644 --- a/.github/labels.yml +++ b/.github/labels.yml @@ -201,3 +201,6 @@ - name: "license-review-required" color: "EDEDED" description: "This PR requires a license review" +- name: "Gittensor" + color: "8B5CF6" + description: "Pull request from a Gittensor (Bittensor SN74) miner — tracked at gittensor.io" diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 26c5f55fa0..f0a2badf1b 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -47,3 +47,66 @@ jobs: name: playwright-nightly-${{ github.run_id }} path: frontend/playwright-report/ retention-days: 14 + + label-gittensor-prs: + name: Label PRs tracked by Gittensor + runs-on: ubuntu-latest + permissions: + pull-requests: write + steps: + - name: Harden the runner (Audit all outbound calls) + uses: step-security/harden-runner@8d3c67de8e2fe68ef647c8db1e6a09f647780f40 # v2.19.0 + with: + egress-policy: audit + + - name: Apply Gittensor label + uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 + with: + script: | + const LABEL = "Gittensor"; + const repoFull = `${context.repo.owner}/${context.repo.repo}`; + const repoKey = repoFull.toLowerCase(); + + const res = await fetch("https://api.gittensor.io/prs", { + headers: { + accept: "application/json", + "user-agent": "Mozilla/5.0 (gha-gittensor-labeler)", + }, + }); + if (!res.ok) { + throw new Error(`Gittensor API returned ${res.status} ${res.statusText}`); + } + const data = await res.json(); + + const numbers = [...new Set( + data + .filter(p => p.repository && p.repository.toLowerCase() === repoKey) + .map(p => p.pullRequestNumber) + .filter(n => Number.isInteger(n) && n > 0) + )]; + core.info(`Gittensor reports ${numbers.length} tracked PRs for ${repoFull}`); + + let added = 0, skipped = 0, failed = 0; + for (const issue_number of numbers) { + try { + const existing = await github.rest.issues.listLabelsOnIssue({ + ...context.repo, + issue_number, + }); + if (existing.data.some(l => l.name === LABEL)) { + skipped++; + continue; + } + await github.rest.issues.addLabels({ + ...context.repo, + issue_number, + labels: [LABEL], + }); + core.info(`#${issue_number}: added "${LABEL}"`); + added++; + } catch (e) { + core.warning(`#${issue_number}: ${e.message}`); + failed++; + } + } + core.notice(`Gittensor labeling: ${added} added, ${skipped} already labeled, ${failed} failed`);