diff --git a/src/negative_test/github-action/composite-output-missing-value.json b/src/negative_test/github-action/composite-output-missing-value.json new file mode 100644 index 00000000000..94588ee7440 --- /dev/null +++ b/src/negative_test/github-action/composite-output-missing-value.json @@ -0,0 +1,18 @@ +{ + "description": "Composite action with an output missing its value", + "name": "Test composite output without value", + "outputs": { + "result": { + "description": "Missing value" + } + }, + "runs": { + "steps": [ + { + "run": "echo test", + "shell": "bash" + } + ], + "using": "composite" + } +} diff --git a/src/negative_test/github-action/javascript-output-with-value.json b/src/negative_test/github-action/javascript-output-with-value.json new file mode 100644 index 00000000000..95efa6ccbc0 --- /dev/null +++ b/src/negative_test/github-action/javascript-output-with-value.json @@ -0,0 +1,14 @@ +{ + "description": "JavaScript action with a composite-only output value", + "name": "Test JavaScript output with value", + "outputs": { + "result": { + "description": "Unexpected value", + "value": "${{ steps.test.outputs.result }}" + } + }, + "runs": { + "main": "index.js", + "using": "node24" + } +} diff --git a/src/schemas/json/github-action.json b/src/schemas/json/github-action.json index fe8fc78c048..83068c489ca 100644 --- a/src/schemas/json/github-action.json +++ b/src/schemas/json/github-action.json @@ -300,20 +300,7 @@ "additionalProperties": false } }, - "additionalProperties": false, - "dependencies": { - "runs": { - "type": "object", - "properties": { - "using": { - "not": { - "const": "composite" - } - } - }, - "required": ["using"] - } - } + "additionalProperties": false }, "outputs-composite": { "$comment": "https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#outputs-for-composite-actions", @@ -340,16 +327,24 @@ "additionalProperties": false } }, - "additionalProperties": false, - "dependencies": { - "runs": { - "type": "object", - "properties": { - "using": { - "const": "composite" - } - }, - "required": ["using"] + "additionalProperties": false + } + }, + "else": { + "properties": { + "outputs": { + "$ref": "#/definitions/outputs" + } + } + }, + "if": { + "properties": { + "runs": { + "type": "object", + "properties": { + "using": { + "const": "composite" + } } } } @@ -407,14 +402,7 @@ "additionalProperties": false }, "outputs": { - "oneOf": [ - { - "$ref": "#/definitions/outputs-composite" - }, - { - "$ref": "#/definitions/outputs" - } - ] + "$comment": "Because of `additionalProperties: false`, this empty schema is needed to allow the `outputs` property. The `outputs` subschema is determined by the if/then/else keywords." }, "runs": { "oneOf": [ @@ -719,5 +707,12 @@ } }, "required": ["name", "description", "runs"], + "then": { + "properties": { + "outputs": { + "$ref": "#/definitions/outputs-composite" + } + } + }, "type": "object" } diff --git a/src/test/github-action/output-id-runs.json b/src/test/github-action/output-id-runs.json new file mode 100644 index 00000000000..2145a9d3a52 --- /dev/null +++ b/src/test/github-action/output-id-runs.json @@ -0,0 +1,13 @@ +{ + "description": "JavaScript action with an output named runs", + "name": "Test output named runs", + "outputs": { + "runs": { + "description": "An output whose identifier matches a top-level property" + } + }, + "runs": { + "main": "index.js", + "using": "node24" + } +} diff --git a/src/test/github-action/outputs-empty.json b/src/test/github-action/outputs-empty.json new file mode 100644 index 00000000000..f252cd6e3c2 --- /dev/null +++ b/src/test/github-action/outputs-empty.json @@ -0,0 +1,9 @@ +{ + "description": "JavaScript action with an empty output map", + "name": "Test empty outputs", + "outputs": {}, + "runs": { + "main": "index.js", + "using": "node24" + } +}