feat: add some env from github action
This commit is contained in:
parent
2ccf302b69
commit
861d6e1adb
22
main.go
22
main.go
@ -98,9 +98,14 @@ func main() {
|
|||||||
EnvVar: "PLUGIN_FORMAT",
|
EnvVar: "PLUGIN_FORMAT",
|
||||||
},
|
},
|
||||||
cli.StringFlag{
|
cli.StringFlag{
|
||||||
Name: "repo.owner",
|
Name: "repo",
|
||||||
Usage: "repository owner",
|
Usage: "repository owner and repository name",
|
||||||
EnvVar: "DRONE_REPO_OWNER",
|
EnvVar: "DRONE_REPO,GITHUB_REPOSITORY",
|
||||||
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "repo.namespace",
|
||||||
|
Usage: "repository namespace",
|
||||||
|
EnvVar: "DRONE_REPO_NAMESPACE,GITHUB_ACTOR",
|
||||||
},
|
},
|
||||||
cli.StringFlag{
|
cli.StringFlag{
|
||||||
Name: "repo.name",
|
Name: "repo.name",
|
||||||
@ -190,6 +195,11 @@ func main() {
|
|||||||
Usage: "source env file",
|
Usage: "source env file",
|
||||||
EnvVar: "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
|
app.Version = Version
|
||||||
@ -210,8 +220,9 @@ func run(c *cli.Context) error {
|
|||||||
|
|
||||||
plugin := Plugin{
|
plugin := Plugin{
|
||||||
Repo: Repo{
|
Repo: Repo{
|
||||||
Owner: c.String("repo.owner"),
|
FullName: c.String("repo"),
|
||||||
Name: c.String("repo.name"),
|
Namespace: c.String("repo.namespace"),
|
||||||
|
Name: c.String("repo.name"),
|
||||||
},
|
},
|
||||||
Commit: Commit{
|
Commit: Commit{
|
||||||
Sha: c.String("commit.sha"),
|
Sha: c.String("commit.sha"),
|
||||||
@ -248,6 +259,7 @@ func run(c *cli.Context) error {
|
|||||||
Video: c.StringSlice("video"),
|
Video: c.StringSlice("video"),
|
||||||
Venue: c.StringSlice("venue"),
|
Venue: c.StringSlice("venue"),
|
||||||
Format: c.String("format"),
|
Format: c.String("format"),
|
||||||
|
GitHub: c.Bool("github"),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,8 +15,9 @@ import (
|
|||||||
type (
|
type (
|
||||||
// Repo information.
|
// Repo information.
|
||||||
Repo struct {
|
Repo struct {
|
||||||
Owner string
|
FullName string
|
||||||
Name string
|
Namespace string
|
||||||
|
Name string
|
||||||
}
|
}
|
||||||
|
|
||||||
// Commit information.
|
// Commit information.
|
||||||
@ -59,6 +60,7 @@ type (
|
|||||||
Video []string
|
Video []string
|
||||||
Venue []string
|
Venue []string
|
||||||
Format string
|
Format string
|
||||||
|
GitHub bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// Plugin values.
|
// Plugin values.
|
||||||
@ -259,7 +261,7 @@ func (p Plugin) Exec() error {
|
|||||||
p.Build.Link = escapeMarkdownOne(p.Build.Link)
|
p.Build.Link = escapeMarkdownOne(p.Build.Link)
|
||||||
p.Build.PR = escapeMarkdownOne(p.Build.PR)
|
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)
|
p.Repo.Name = escapeMarkdownOne(p.Repo.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,8 +30,8 @@ func TestMissingUserConfig(t *testing.T) {
|
|||||||
func TestDefaultMessageFormat(t *testing.T) {
|
func TestDefaultMessageFormat(t *testing.T) {
|
||||||
plugin := Plugin{
|
plugin := Plugin{
|
||||||
Repo: Repo{
|
Repo: Repo{
|
||||||
Name: "go-hello",
|
Name: "go-hello",
|
||||||
Owner: "appleboy",
|
Namespace: "appleboy",
|
||||||
},
|
},
|
||||||
Commit: Commit{
|
Commit: Commit{
|
||||||
Sha: "e7c4f0a63ceeb42a39ac7806f7b51f3f0d204fd2",
|
Sha: "e7c4f0a63ceeb42a39ac7806f7b51f3f0d204fd2",
|
||||||
@ -54,8 +54,8 @@ func TestDefaultMessageFormat(t *testing.T) {
|
|||||||
func TestSendMessage(t *testing.T) {
|
func TestSendMessage(t *testing.T) {
|
||||||
plugin := Plugin{
|
plugin := Plugin{
|
||||||
Repo: Repo{
|
Repo: Repo{
|
||||||
Name: "go-hello",
|
Name: "go-hello",
|
||||||
Owner: "appleboy",
|
Namespace: "appleboy",
|
||||||
},
|
},
|
||||||
Commit: Commit{
|
Commit: Commit{
|
||||||
Sha: "e7c4f0a63ceeb42a39ac7806f7b51f3f0d204fd2",
|
Sha: "e7c4f0a63ceeb42a39ac7806f7b51f3f0d204fd2",
|
||||||
@ -104,8 +104,8 @@ func TestSendMessage(t *testing.T) {
|
|||||||
func TestBotError(t *testing.T) {
|
func TestBotError(t *testing.T) {
|
||||||
plugin := Plugin{
|
plugin := Plugin{
|
||||||
Repo: Repo{
|
Repo: Repo{
|
||||||
Name: "go-hello",
|
Name: "go-hello",
|
||||||
Owner: "appleboy",
|
Namespace: "appleboy",
|
||||||
},
|
},
|
||||||
Commit: Commit{
|
Commit: Commit{
|
||||||
Sha: "e7c4f0a63ceeb42a39ac7806f7b51f3f0d204fd2",
|
Sha: "e7c4f0a63ceeb42a39ac7806f7b51f3f0d204fd2",
|
||||||
@ -279,8 +279,8 @@ func TestConvertLocation(t *testing.T) {
|
|||||||
func TestHTMLMessage(t *testing.T) {
|
func TestHTMLMessage(t *testing.T) {
|
||||||
plugin := Plugin{
|
plugin := Plugin{
|
||||||
Repo: Repo{
|
Repo: Repo{
|
||||||
Name: "go-hello",
|
Name: "go-hello",
|
||||||
Owner: "appleboy",
|
Namespace: "appleboy",
|
||||||
},
|
},
|
||||||
Commit: Commit{
|
Commit: Commit{
|
||||||
Sha: "e7c4f0a63ceeb42a39ac7806f7b51f3f0d204fd2",
|
Sha: "e7c4f0a63ceeb42a39ac7806f7b51f3f0d204fd2",
|
||||||
|
Loading…
Reference in New Issue
Block a user