diff --git a/main.go b/main.go index d2d5cb4..954f03a 100644 --- a/main.go +++ b/main.go @@ -98,9 +98,14 @@ func main() { EnvVar: "PLUGIN_FORMAT", }, cli.StringFlag{ - Name: "repo.owner", - Usage: "repository owner", - EnvVar: "DRONE_REPO_OWNER", + Name: "repo", + Usage: "repository owner and repository name", + EnvVar: "DRONE_REPO,GITHUB_REPOSITORY", + }, + cli.StringFlag{ + Name: "repo.namespace", + Usage: "repository namespace", + EnvVar: "DRONE_REPO_NAMESPACE,GITHUB_ACTOR", }, cli.StringFlag{ Name: "repo.name", @@ -190,6 +195,11 @@ func main() { Usage: "source env file", EnvVar: "ENV_FILE", }, + cli.BoolFlag{ + Name: "github", + Usage: "Boolean value, indicates the runtime environment is GitHub Action.", + EnvVar: "PLUGIN_GITHUB,GITHUB", + }, } app.Version = Version @@ -210,8 +220,9 @@ func run(c *cli.Context) error { plugin := Plugin{ Repo: Repo{ - Owner: c.String("repo.owner"), - Name: c.String("repo.name"), + FullName: c.String("repo"), + Namespace: c.String("repo.namespace"), + Name: c.String("repo.name"), }, Commit: Commit{ Sha: c.String("commit.sha"), @@ -248,6 +259,7 @@ func run(c *cli.Context) error { Video: c.StringSlice("video"), Venue: c.StringSlice("venue"), Format: c.String("format"), + GitHub: c.Bool("github"), }, } diff --git a/plugin.go b/plugin.go index 0d09482..45f3ebe 100644 --- a/plugin.go +++ b/plugin.go @@ -15,8 +15,9 @@ import ( type ( // Repo information. Repo struct { - Owner string - Name string + FullName string + Namespace string + Name string } // Commit information. @@ -59,6 +60,7 @@ type ( Video []string Venue []string Format string + GitHub bool } // Plugin values. @@ -259,7 +261,7 @@ func (p Plugin) Exec() error { p.Build.Link = escapeMarkdownOne(p.Build.Link) p.Build.PR = escapeMarkdownOne(p.Build.PR) - p.Repo.Owner = escapeMarkdownOne(p.Repo.Owner) + p.Repo.Namespace = escapeMarkdownOne(p.Repo.Namespace) p.Repo.Name = escapeMarkdownOne(p.Repo.Name) } diff --git a/plugin_test.go b/plugin_test.go index 2695438..e3bac2f 100644 --- a/plugin_test.go +++ b/plugin_test.go @@ -30,8 +30,8 @@ func TestMissingUserConfig(t *testing.T) { func TestDefaultMessageFormat(t *testing.T) { plugin := Plugin{ Repo: Repo{ - Name: "go-hello", - Owner: "appleboy", + Name: "go-hello", + Namespace: "appleboy", }, Commit: Commit{ Sha: "e7c4f0a63ceeb42a39ac7806f7b51f3f0d204fd2", @@ -54,8 +54,8 @@ func TestDefaultMessageFormat(t *testing.T) { func TestSendMessage(t *testing.T) { plugin := Plugin{ Repo: Repo{ - Name: "go-hello", - Owner: "appleboy", + Name: "go-hello", + Namespace: "appleboy", }, Commit: Commit{ Sha: "e7c4f0a63ceeb42a39ac7806f7b51f3f0d204fd2", @@ -104,8 +104,8 @@ func TestSendMessage(t *testing.T) { func TestBotError(t *testing.T) { plugin := Plugin{ Repo: Repo{ - Name: "go-hello", - Owner: "appleboy", + Name: "go-hello", + Namespace: "appleboy", }, Commit: Commit{ Sha: "e7c4f0a63ceeb42a39ac7806f7b51f3f0d204fd2", @@ -279,8 +279,8 @@ func TestConvertLocation(t *testing.T) { func TestHTMLMessage(t *testing.T) { plugin := Plugin{ Repo: Repo{ - Name: "go-hello", - Owner: "appleboy", + Name: "go-hello", + Namespace: "appleboy", }, Commit: Commit{ Sha: "e7c4f0a63ceeb42a39ac7806f7b51f3f0d204fd2",