Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/pr-backport.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
20 changes: 17 additions & 3 deletions scripts/cicd/backport-missing-trigger.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, string>
}

interface WorkflowJob {
env?: Record<string, string>
steps?: WorkflowStep[]
}

interface Workflow {
jobs?: Record<string, { steps?: Array<{ run?: string }> }>
jobs?: Partial<Record<string, WorkflowJob>>
}

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
Expand Down Expand Up @@ -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)
})
})
Loading