From f7ecb3ead518abf9cc1b595ee9ecaa42841ad523 Mon Sep 17 00:00:00 2001 From: bymyself Date: Fri, 30 Oct 2026 00:08:21 +0000 Subject: [PATCH] fix(ci): post the missing needs-backport warning with the PR token The warn-missing-needs-backport job posted with github.token, which the issues comment endpoint refuses here (HTTP 403, 'Resource not accessible by integration'), the same limit the backport job already works around with PR_GH_TOKEN. The step only logs a warning on failure, so authors never saw that their release labels started no backport. Use the backport job's token, and pin that in the workflow test. --- .github/workflows/pr-backport.yaml | 2 +- scripts/cicd/backport-missing-trigger.test.ts | 20 ++++++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pr-backport.yaml b/.github/workflows/pr-backport.yaml index a7844efe3cc..1c8203357ba 100644 --- a/.github/workflows/pr-backport.yaml +++ b/.github/workflows/pr-backport.yaml @@ -696,7 +696,7 @@ jobs: steps: - name: Comment when release labels lack needs-backport env: - GH_TOKEN: ${{ github.token }} + GH_TOKEN: ${{ secrets.PR_GH_TOKEN || secrets.GH_TOKEN }} GH_REPO: ${{ github.repository }} PR_NUMBER: ${{ github.event.pull_request.number }} run: | diff --git a/scripts/cicd/backport-missing-trigger.test.ts b/scripts/cicd/backport-missing-trigger.test.ts index 66131e44a18..ce27b6113ad 100644 --- a/scripts/cicd/backport-missing-trigger.test.ts +++ b/scripts/cicd/backport-missing-trigger.test.ts @@ -12,15 +12,25 @@ import { join } from 'node:path' import { describe, expect, it, onTestFinished } from 'vitest' import { parse } from 'yaml' +interface WorkflowStep { + run?: string + env?: Record +} + +interface WorkflowJob { + env?: Record + steps?: WorkflowStep[] +} + interface Workflow { - jobs?: Record }> + jobs?: Partial> } const workflow = parse( readFileSync('.github/workflows/pr-backport.yaml', 'utf8') ) as Workflow -const warnScript = - workflow.jobs?.['warn-missing-needs-backport']?.steps?.[0]?.run ?? '' +const warnStep = workflow.jobs?.['warn-missing-needs-backport']?.steps?.[0] +const warnScript = warnStep?.run ?? '' const fakeGh = `#!/usr/bin/env bash set -euo pipefail @@ -260,4 +270,8 @@ describe('backport warning for release labels without needs-backport', () => { expect(result.stdout).toContain('::warning::') expect(result.stdout).toContain('core/1.57') }) + + it('posts with the same token the backport job uses, since the auto-provided one is refused', () => { + expect(warnStep?.env?.GH_TOKEN).toBe(workflow.jobs?.backport?.env?.GH_TOKEN) + }) })