Update references to Job and Step

This commit is contained in:
Josh Gross
2022-12-01 11:11:03 -05:00
parent ffb16dbdee
commit f4295a4d43
2 changed files with 6 additions and 6 deletions
@@ -1,5 +1,5 @@
import {WorkflowTemplate} from "@github/actions-workflow-parser"; import {WorkflowTemplate} from "@github/actions-workflow-parser";
import {JobConfig, StepConfig} from "@github/actions-workflow-parser/model/workflow-template"; import {Job, Step} from "@github/actions-workflow-parser/model/workflow-template";
import {StringToken} from "@github/actions-workflow-parser/templates/tokens/string-token"; import {StringToken} from "@github/actions-workflow-parser/templates/tokens/string-token";
import {TemplateToken} from "@github/actions-workflow-parser/templates/tokens/template-token"; import {TemplateToken} from "@github/actions-workflow-parser/templates/tokens/template-token";
@@ -9,10 +9,10 @@ export interface WorkflowContext {
template: WorkflowTemplate | undefined; template: WorkflowTemplate | undefined;
/** If the context is for a position within a job, this will be the job */ /** If the context is for a position within a job, this will be the job */
job?: JobConfig; job?: Job;
/** If the context is for a position within a step, this will be the step */ /** If the context is for a position within a step, this will be the step */
step?: StepConfig; step?: Step;
} }
export function getWorkflowContext( export function getWorkflowContext(
@@ -30,7 +30,7 @@ export function getWorkflowContext(
switch (token.definition?.key) { switch (token.definition?.key) {
case "job-id": { case "job-id": {
const jobID = (token as StringToken).value; const jobID = (token as StringToken).value;
context.job = template.jobs.find(job => job.id === jobID); context.job = template.jobs.find(job => job.id.value === jobID);
} }
} }
} }
@@ -8,6 +8,6 @@ export async function needs(context: WorkflowContext): Promise<Value[]> {
const uniquejobIDs = new Set(context.template.jobs.map(j => j.id)).values(); const uniquejobIDs = new Set(context.template.jobs.map(j => j.id)).values();
return Array.from(uniquejobIDs) return Array.from(uniquejobIDs)
.filter(x => x !== context.job?.id) .filter(x => x.value !== context.job?.id.value)
.map(x => ({label: x})); .map(x => ({label: x.value}));
} }