Skip to content

Commit 2c8d5f1

Browse files
authored
Allow steps.*.outputs.* in github-token expressions for same-job safe-output auth (#48101)
1 parent b5a7dcd commit 2c8d5f1

5 files changed

Lines changed: 127 additions & 53 deletions

File tree

pkg/parser/schema_test.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1227,6 +1227,46 @@ func TestMainWorkflowSchema_CreateDiscussionRequiredCategoryAllowed(t *testing.T
12271227
}
12281228
}
12291229

1230+
func TestMainWorkflowSchema_GitHubTokenAllowsStepOutputs(t *testing.T) {
1231+
t.Parallel()
1232+
1233+
frontmatter := map[string]any{
1234+
"on": "daily",
1235+
"safe-outputs": map[string]any{
1236+
"github-token": "${{ steps.fetch-token.outputs.my-token }}",
1237+
"create-issue": map[string]any{
1238+
"github-token": "${{ steps.fetch-token.outputs.my-token }}",
1239+
},
1240+
},
1241+
}
1242+
1243+
if err := validateWithSchema(frontmatter, mainWorkflowSchema, "main workflow file"); err != nil {
1244+
t.Fatalf("expected steps.*.outputs.* github-token expression to pass schema validation, got: %v", err)
1245+
}
1246+
}
1247+
1248+
func TestMainWorkflowSchema_SkillsGitHubTokenRejectsStepOutputs(t *testing.T) {
1249+
t.Parallel()
1250+
1251+
frontmatter := map[string]any{
1252+
"on": "daily",
1253+
"skills": []any{
1254+
map[string]any{
1255+
"skill": "githubnext/skills@1f181b37d3fe5862ab590648f25a292e345b5de6",
1256+
"github-token": "${{ steps.fetch-token.outputs.my-token }}",
1257+
},
1258+
},
1259+
}
1260+
1261+
err := validateWithSchema(frontmatter, mainWorkflowSchema, "main workflow file")
1262+
if err == nil {
1263+
t.Fatal("expected skills[].github-token steps.*.outputs.* expression to fail schema validation")
1264+
}
1265+
if !strings.Contains(err.Error(), "github-token") {
1266+
t.Fatalf("expected schema error to mention github-token, got: %v", err)
1267+
}
1268+
}
1269+
12301270
func TestMainWorkflowSchemaPushToPullRequestBranchHasMaxPatchSize(t *testing.T) {
12311271
schemaPath := "schemas/main_workflow_schema.json"
12321272
schemaContent, err := os.ReadFile(schemaPath)

0 commit comments

Comments
 (0)