Skip to content

Commit 5931fd0

Browse files
Fix: ensure Linear/Jira tasks are handled even on push events and skip trigger check
Co-authored-by: Junie <junie@jetbrains.com>
1 parent 15dbe2e commit 5931fd0

3 files changed

Lines changed: 30 additions & 6 deletions

File tree

src/github/context.ts

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -254,11 +254,29 @@ export function extractJunieWorkflowContext(tokenOwner: TokenOwner): JunieExecut
254254
}
255255
case "push": {
256256
const payload = context.payload as PushEvent;
257-
parsedContext = {
257+
258+
const baseContext = {
258259
...commonFields,
259260
eventName: context.eventName,
260261
payload: payload
261262
};
263+
264+
// Support triggered Linear/Jira tasks even on push events (e.g. for testing)
265+
if (process.env.LINEAR_API_TOKEN && process.env.ALL_INPUTS) {
266+
try {
267+
const allInputs = JSON.parse(process.env.ALL_INPUTS);
268+
if (allInputs.action === LINEAR_EVENT_ACTION) {
269+
return extractLinearEventData({ inputs: allInputs } as any, commonFields);
270+
}
271+
if (allInputs.action === JIRA_EVENT_ACTION) {
272+
return extractJiraEventData({ inputs: allInputs } as any, commonFields);
273+
}
274+
} catch (e) {
275+
console.warn("Failed to parse ALL_INPUTS for action check:", e);
276+
}
277+
}
278+
279+
parsedContext = baseContext;
262280
break
263281
}
264282
case "workflow_dispatch": {
@@ -459,19 +477,19 @@ function extractLinearEventData(workflowPayload: WorkflowDispatchEvent, context:
459477
export function isJiraWorkflowDispatchEvent(context: JunieExecutionContext): context is AutomationEventContext & {
460478
payload: JiraIssuePayload
461479
} {
462-
return context.eventName === "workflow_dispatch" && 'action' in context.payload && context.payload.action === JIRA_EVENT_ACTION;
480+
return 'action' in context.payload && context.payload.action === JIRA_EVENT_ACTION;
463481
}
464482

465483
export function isLinearWorkflowDispatchEvent(context: JunieExecutionContext): context is AutomationEventContext & {
466484
payload: LinearIssuePayload
467485
} {
468-
return context.eventName === "workflow_dispatch" && 'action' in context.payload && context.payload.action === LINEAR_EVENT_ACTION;
486+
return 'action' in context.payload && context.payload.action === LINEAR_EVENT_ACTION;
469487
}
470488

471489
export function isResolveConflictsWorkflowDispatchEvent(context: JunieExecutionContext): context is AutomationEventContext & {
472490
payload: ResolveConflictsEventPayload
473491
} {
474-
return context.eventName === "workflow_dispatch" && 'action' in context.payload && context.payload.action === RESOLVE_CONFLICTS_ACTION;
492+
return 'action' in context.payload && context.payload.action === RESOLVE_CONFLICTS_ACTION;
475493
}
476494

477495
export function isCheckSuiteEvent(context: JunieExecutionContext): context is AutomationEventContext & {

src/github/junie/prepare-junie.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ export async function initializeJunieExecution({
111111
async function shouldHandle(context: JunieExecutionContext, octokit: Octokits): Promise<boolean> {
112112
console.log(`Checking if Junie should handle event: ${context.eventName}`);
113113
if (isLinearWorkflowDispatchEvent(context)) {
114-
console.log("✓ Linear workflow dispatch detected - handling task");
114+
console.log("✓ Linear task detected - handling task");
115115
try {
116116
getLinearClient(); // Just to verify token early
117117
} catch (e) {
@@ -122,7 +122,7 @@ async function shouldHandle(context: JunieExecutionContext, octokit: Octokits):
122122
}
123123

124124
if (isJiraWorkflowDispatchEvent(context)) {
125-
console.log("✓ Jira workflow dispatch detected - handling task");
125+
console.log("✓ Jira task detected - handling task");
126126
return true;
127127
}
128128

src/github/validation/trigger.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ export function detectJunieTriggerPhrase(context: JunieExecutionContext): boolea
1919
const {
2020
inputs: {assigneeTrigger, labelTrigger, triggerPhrase},
2121
} = context;
22+
23+
// Linear/Jira tasks are pre-validated in shouldHandle and don't require trigger phrase
24+
if ('action' in context.payload && (context.payload.action === 'linear_event' || context.payload.action === 'jira_event')) {
25+
return true;
26+
}
27+
2228
const triggerPhraseRegex = new RegExp(`(^|\\s)${escapeRegExp(triggerPhrase)}([\\s.,!?;:]|$)`, 'i');
2329

2430
if (isIssuesAssignedEvent(context)) {

0 commit comments

Comments
 (0)