Merge pull request #25 from github/joshmgross/update-job-references

Update references to `Job` and `Step`
This commit is contained in:
Josh Gross
2022-12-01 14:45:41 -05:00
committed by GitHub
3 changed files with 12 additions and 12 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}));
} }
+6 -6
View File
@@ -665,9 +665,9 @@
"link": true "link": true
}, },
"node_modules/@github/actions-workflow-parser": { "node_modules/@github/actions-workflow-parser": {
"version": "0.0.20", "version": "0.0.23",
"resolved": "https://npm.pkg.github.com/download/@github/actions-workflow-parser/0.0.20/cfba09f790505ad7f811d3ba63981f9a22562b82", "resolved": "https://npm.pkg.github.com/download/@github/actions-workflow-parser/0.0.23/4fe24783761ab3ae620f6a4199c27f6d1bd2da03",
"integrity": "sha512-85C1iony9CclubBCGFNY3wcvDE+FeGHZ92bEYd5XdseFEtAU5UjAF85nBAd55mEzEh+f/mJq8RK3s0rMLqv5pQ==", "integrity": "sha512-oYV5pKB9jryDM8BKzR0amuL96Xhq/aCswffv/ugQntogmKPQloYFJQv1Rpe9WMFQvM4Ws2KpYvpBsVwS3rwZyw==",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@github/actions-expressions": "*", "@github/actions-expressions": "*",
@@ -10927,9 +10927,9 @@
} }
}, },
"@github/actions-workflow-parser": { "@github/actions-workflow-parser": {
"version": "0.0.20", "version": "0.0.23",
"resolved": "https://npm.pkg.github.com/download/@github/actions-workflow-parser/0.0.20/cfba09f790505ad7f811d3ba63981f9a22562b82", "resolved": "https://npm.pkg.github.com/download/@github/actions-workflow-parser/0.0.23/4fe24783761ab3ae620f6a4199c27f6d1bd2da03",
"integrity": "sha512-85C1iony9CclubBCGFNY3wcvDE+FeGHZ92bEYd5XdseFEtAU5UjAF85nBAd55mEzEh+f/mJq8RK3s0rMLqv5pQ==", "integrity": "sha512-oYV5pKB9jryDM8BKzR0amuL96Xhq/aCswffv/ugQntogmKPQloYFJQv1Rpe9WMFQvM4Ws2KpYvpBsVwS3rwZyw==",
"requires": { "requires": {
"@github/actions-expressions": "*", "@github/actions-expressions": "*",
"yaml": "^2.0.0-8" "yaml": "^2.0.0-8"