Skip to content

Commit

Permalink
Add destination path templating for create-mode prs (#490)
Browse files Browse the repository at this point in the history
Useful for super polymorphic automations where you need to parameterize filepaths
  • Loading branch information
michaeljguarino authored Feb 14, 2024
1 parent 8b56b73 commit 4010793
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pkg/pr/creates.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,13 @@ func applyCreates(creates *CreateSpec, ctx map[string]interface{}) error {
source = filepath.Join(creates.ExternalDir, source)
}

if err := replaceTo(source, tpl.Destination, func(data []byte) ([]byte, error) {
destPath := []byte(tpl.Destination)
dest, err := templateReplacement(destPath, ctx)
if err != nil {
dest = destPath
}

if err := replaceTo(source, string(dest), func(data []byte) ([]byte, error) {
return templateReplacement(data, ctx)
}); err != nil {
return err
Expand Down

0 comments on commit 4010793

Please sign in to comment.