fix: resolve YAML anchors and aliases in Actions workflows (#38984) (#38996)

Backport https://github.com/go-gitea/gitea/pull/38984

Workflows using YAML anchors are rejected as invalid, because a workflow
is split into one document per job and an alias whose anchor lands in
another job's document no longer resolves. Node walkers such as `on:`
parsing have no alias case either.

Aliases are now expanded once, right after the workflow is parsed and
before anything reads or splits it, bounded like GitHub's parser so
nested aliases cannot expand without limit. Merge keys stay unsupported,
as they are upstream.

Fixes: https://github.com/go-gitea/gitea/issues/38983
This commit is contained in:
silverwind
2026-08-20 11:16:33 +02:00
committed by GitHub
parent 616dbddda4
commit d8e179f28f
11 changed files with 238 additions and 38 deletions
+1 -2
View File
@@ -4,7 +4,6 @@
package actions
import (
"bytes"
"fmt"
"path"
"slices"
@@ -120,7 +119,7 @@ func GetContentFromEntry(entry *git.TreeEntry) ([]byte, error) {
}
func GetEventsFromContent(content []byte) ([]*jobparser.Event, error) {
workflow, err := model.ReadWorkflow(bytes.NewReader(content))
workflow, err := jobparser.ReadWorkflow(content)
if err != nil {
return nil, err
}