feat: add some env from github action
This commit is contained in:
parent
2ccf302b69
commit
861d6e1adb
20
main.go
20
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,7 +220,8 @@ func run(c *cli.Context) error {
|
||||
|
||||
plugin := Plugin{
|
||||
Repo: Repo{
|
||||
Owner: c.String("repo.owner"),
|
||||
FullName: c.String("repo"),
|
||||
Namespace: c.String("repo.namespace"),
|
||||
Name: c.String("repo.name"),
|
||||
},
|
||||
Commit: Commit{
|
||||
@ -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"),
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,8 @@ import (
|
||||
type (
|
||||
// Repo information.
|
||||
Repo struct {
|
||||
Owner string
|
||||
FullName string
|
||||
Namespace string
|
||||
Name string
|
||||
}
|
||||
|
||||
@ -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)
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@ func TestDefaultMessageFormat(t *testing.T) {
|
||||
plugin := Plugin{
|
||||
Repo: Repo{
|
||||
Name: "go-hello",
|
||||
Owner: "appleboy",
|
||||
Namespace: "appleboy",
|
||||
},
|
||||
Commit: Commit{
|
||||
Sha: "e7c4f0a63ceeb42a39ac7806f7b51f3f0d204fd2",
|
||||
@ -55,7 +55,7 @@ func TestSendMessage(t *testing.T) {
|
||||
plugin := Plugin{
|
||||
Repo: Repo{
|
||||
Name: "go-hello",
|
||||
Owner: "appleboy",
|
||||
Namespace: "appleboy",
|
||||
},
|
||||
Commit: Commit{
|
||||
Sha: "e7c4f0a63ceeb42a39ac7806f7b51f3f0d204fd2",
|
||||
@ -105,7 +105,7 @@ func TestBotError(t *testing.T) {
|
||||
plugin := Plugin{
|
||||
Repo: Repo{
|
||||
Name: "go-hello",
|
||||
Owner: "appleboy",
|
||||
Namespace: "appleboy",
|
||||
},
|
||||
Commit: Commit{
|
||||
Sha: "e7c4f0a63ceeb42a39ac7806f7b51f3f0d204fd2",
|
||||
@ -280,7 +280,7 @@ func TestHTMLMessage(t *testing.T) {
|
||||
plugin := Plugin{
|
||||
Repo: Repo{
|
||||
Name: "go-hello",
|
||||
Owner: "appleboy",
|
||||
Namespace: "appleboy",
|
||||
},
|
||||
Commit: Commit{
|
||||
Sha: "e7c4f0a63ceeb42a39ac7806f7b51f3f0d204fd2",
|
||||
|
Loading…
Reference in New Issue
Block a user