-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate to using template for Github PR commens (#12)
* Migrate to using template for gh comment msg * Spelling * Streamline arg flags with "-"format * Update error message in template.go Co-authored-by: Bjørn <[email protected]> * edit message-template description * Use pointer w message-template Co-authored-by: Bjørn <[email protected]>
- Loading branch information
1 parent
5642ac2
commit c617f32
Showing
4 changed files
with
50 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package main | ||
|
||
import ( | ||
"strings" | ||
"text/template" | ||
|
||
"github.com/pkg/errors" | ||
) | ||
|
||
type BotMessageData struct { | ||
Template string | ||
Branch string | ||
AutoReleaseEnvironments []string | ||
} | ||
|
||
func BotMessage(data BotMessageData) (string, error) { | ||
var message strings.Builder | ||
|
||
template := template.New("test") | ||
template, err := template.Parse(data.Template) | ||
if err != nil { | ||
return "", errors.Wrapf(err, "parsing template: '%s'", data.Template) | ||
} | ||
|
||
err = template.Execute(&message, data) | ||
if err != nil { | ||
return "", errors.Wrap(err, "applying template to data") | ||
} | ||
|
||
return message.String(), nil | ||
} |