-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathindex.ts
More file actions
73 lines (63 loc) · 2.18 KB
/
Copy pathindex.ts
File metadata and controls
73 lines (63 loc) · 2.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import * as core from '@actions/core'
import {getInputs} from './inputs'
import {findPRs} from './prs'
import {buildPrompt} from './prompt'
import {ensureCopilotCLI, runCopilot} from './copilot'
import {parseOutput, setOutputs} from './outputs'
async function run(): Promise<void> {
try {
// 1. Parse inputs
core.info('📋 Parsing inputs...')
const inputs = getInputs()
core.info(
`Comparing ${inputs.baseRef}..${inputs.headRef} using ${inputs.prStrategy} strategy`
)
// 2. Find PRs between refs
core.info('🔍 Finding PRs between refs...')
const prs = await findPRs(inputs.baseRef, inputs.headRef, inputs.prStrategy)
if (prs.length === 0) {
core.warning('No PRs found — nothing to generate')
setOutputs({entries: [], uncertainEntries: [], skippedPRs: []})
return
}
core.info(`Found ${prs.length} PR(s) to analyze`)
// 3. Build the prompt
core.info('📝 Building prompt...')
const prompt = buildPrompt(
prs,
inputs.baseRef,
inputs.headRef,
inputs.instructionsPath
)
// 4. Ensure Copilot CLI is available
core.info('🤖 Setting up Copilot CLI...')
const copilotPath = await ensureCopilotCLI()
// 5. Run Copilot CLI
core.info('🚀 Running Copilot CLI...')
const result = await runCopilot(copilotPath, prompt, inputs.model)
// 6. Parse output and set action outputs
core.info('📊 Parsing results...')
const parsed = parseOutput(result.stdout)
// Detect silent failures — PRs found but nothing generated
const totalOutput =
parsed.entries.length +
parsed.uncertainEntries.length +
parsed.skippedPRs.length
if (totalOutput === 0 && prs.length > 0) {
core.warning(
`⚠️ Found ${prs.length} PR(s) but generated 0 release notes. ` +
`Copilot CLI output may be malformed or the model may have failed. ` +
`Check the workflow logs for details.`
)
}
setOutputs(parsed)
core.info('✅ Release notes generation complete!')
} catch (error) {
if (error instanceof Error) {
core.setFailed(error.message)
} else {
core.setFailed('An unexpected error occurred')
}
}
}
run()