mirror of
https://github.com/appleboy/drone-discord.git
synced 2026-06-04 18:33:47 +08:00
feat: add support for specifying source branch in build configuration
- Add a new flag `source.branch` with default value `develop` and usage description "git source branch" - Add a new struct `Source` with a `Branch` field - Add a new field `Source` to the existing struct `Build` - Add a new test case with `Source.Branch` set to "feature/awesome-feature" Signed-off-by: appleboy <appleboy.tw@gmail.com>
This commit is contained in:
@@ -143,6 +143,12 @@ func main() {
|
||||
Usage: "commit message",
|
||||
EnvVar: "DRONE_COMMIT_MESSAGE",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "source.branch",
|
||||
Value: "develop",
|
||||
Usage: "git source branch",
|
||||
EnvVar: "DRONE_SOURCE_BRANCH",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "build.event",
|
||||
Value: "push",
|
||||
@@ -251,6 +257,9 @@ func run(c *cli.Context) error {
|
||||
Avatar: c.String("commit.author.avatar"),
|
||||
Message: c.String("commit.message"),
|
||||
},
|
||||
Source: Source{
|
||||
Branch: c.String("source.branch"),
|
||||
},
|
||||
Build: Build{
|
||||
Tag: c.String("build.tag"),
|
||||
Number: c.Int("build.number"),
|
||||
|
||||
@@ -52,6 +52,10 @@ type (
|
||||
Message string
|
||||
}
|
||||
|
||||
Source struct {
|
||||
Branch string
|
||||
}
|
||||
|
||||
// Build information.
|
||||
Build struct {
|
||||
Tag string
|
||||
@@ -121,6 +125,7 @@ type (
|
||||
GitHub GitHub
|
||||
Repo Repo
|
||||
Build Build
|
||||
Source Source
|
||||
Config Config
|
||||
Payload Payload
|
||||
Commit Commit
|
||||
|
||||
@@ -34,6 +34,9 @@ func TestTemplate(t *testing.T) {
|
||||
Link: "https://github.com/appleboy/go-hello",
|
||||
Event: "tag",
|
||||
},
|
||||
Source: Source{
|
||||
Branch: "feature/awesome-feature",
|
||||
},
|
||||
|
||||
Config: Config{
|
||||
WebhookID: os.Getenv("WEBHOOK_ID"),
|
||||
|
||||
Reference in New Issue
Block a user