Skip to content

Commit 66e7c50

Browse files
committed
chore: update config
1 parent 999af5c commit 66e7c50

File tree

3 files changed

+84
-25
lines changed

3 files changed

+84
-25
lines changed

main.go

Lines changed: 61 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,20 @@ func main() {
102102
EnvVar: "LINE_PORT",
103103
Value: 8088,
104104
},
105+
cli.BoolFlag{
106+
Name: "drone",
107+
Usage: "environment is drone",
108+
EnvVar: "DRONE",
109+
},
110+
cli.StringFlag{
111+
Name: "repo",
112+
Usage: "repository owner and repository name",
113+
EnvVar: "DRONE_REPO,GITHUB_REPOSITORY",
114+
},
105115
cli.StringFlag{
106-
Name: "repo.owner",
107-
Usage: "repository owner",
108-
EnvVar: "DRONE_REPO_OWNER",
116+
Name: "repo.namespace",
117+
Usage: "repository namespace",
118+
EnvVar: "DRONE_REPO_OWNER,DRONE_REPO_NAMESPACE,GITHUB_ACTOR",
109119
},
110120
cli.StringFlag{
111121
Name: "repo.name",
@@ -185,25 +195,55 @@ func main() {
185195
Usage: "pull request",
186196
EnvVar: "DRONE_PULL_REQUEST",
187197
},
188-
cli.Int64Flag{
198+
cli.Float64Flag{
189199
Name: "job.started",
190200
Usage: "job started",
191201
EnvVar: "DRONE_BUILD_STARTED",
192202
},
193-
cli.Int64Flag{
203+
cli.Float64Flag{
194204
Name: "job.finished",
195205
Usage: "job finished",
196206
EnvVar: "DRONE_BUILD_FINISHED",
197207
},
208+
cli.StringFlag{
209+
Name: "env-file",
210+
Usage: "source env file",
211+
},
212+
cli.BoolFlag{
213+
Name: "github",
214+
Usage: "Boolean value, indicates the runtime environment is GitHub Action.",
215+
EnvVar: "PLUGIN_GITHUB,GITHUB",
216+
},
217+
cli.StringFlag{
218+
Name: "github.workflow",
219+
Usage: "The name of the workflow.",
220+
EnvVar: "GITHUB_WORKFLOW",
221+
},
222+
cli.StringFlag{
223+
Name: "github.action",
224+
Usage: "The name of the action.",
225+
EnvVar: "GITHUB_ACTION",
226+
},
227+
cli.StringFlag{
228+
Name: "github.event.name",
229+
Usage: "The webhook name of the event that triggered the workflow.",
230+
EnvVar: "GITHUB_EVENT_NAME",
231+
},
232+
cli.StringFlag{
233+
Name: "github.event.path",
234+
Usage: "The path to a file that contains the payload of the event that triggered the workflow. Value: /github/workflow/event.json.",
235+
EnvVar: "GITHUB_EVENT_PATH",
236+
},
237+
cli.StringFlag{
238+
Name: "github.workspace",
239+
Usage: "The GitHub workspace path. Value: /github/workspace.",
240+
EnvVar: "GITHUB_WORKSPACE",
241+
},
198242
cli.StringFlag{
199243
Name: "deploy.to",
200244
Usage: "Provides the target deployment environment for the running build. This value is only available to promotion and rollback pipelines.",
201245
EnvVar: "DRONE_DEPLOY_TO",
202246
},
203-
cli.StringFlag{
204-
Name: "env-file",
205-
Usage: "source env file",
206-
},
207247
cli.BoolFlag{
208248
Name: "tunnel",
209249
Usage: "Enable tunnel host for webhook",
@@ -275,9 +315,17 @@ func run(c *cli.Context) error {
275315
}
276316

277317
plugin := Plugin{
318+
GitHub: GitHub{
319+
Workflow: c.String("github.workflow"),
320+
Workspace: c.String("github.workspace"),
321+
Action: c.String("github.action"),
322+
EventName: c.String("github.event.name"),
323+
EventPath: c.String("github.event.path"),
324+
},
278325
Repo: Repo{
279-
Owner: c.String("repo.owner"),
280-
Name: c.String("repo.name"),
326+
FullName: c.String("repo"),
327+
Namespace: c.String("repo.namespace"),
328+
Name: c.String("repo.name"),
281329
},
282330
Commit: Commit{
283331
Sha: c.String("commit.sha"),
@@ -295,8 +343,8 @@ func run(c *cli.Context) error {
295343
Event: c.String("build.event"),
296344
Status: c.String("build.status"),
297345
Link: c.String("build.link"),
298-
Started: c.Int64("job.started"),
299-
Finished: c.Int64("job.finished"),
346+
Started: c.Float64("job.started"),
347+
Finished: c.Float64("job.finished"),
300348
PR: c.String("pull.request"),
301349
DeployTo: c.String("deploy.to"),
302350
},

plugin.go

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,20 @@ import (
2323
const defaultPreviewImageURL = "https://cdn4.iconfinder.com/data/icons/miu/24/device-camera-recorder-video-glyph-256.png"
2424

2525
type (
26+
// GitHub information.
27+
GitHub struct {
28+
Workflow string
29+
Workspace string
30+
Action string
31+
EventName string
32+
EventPath string
33+
}
34+
2635
// Repo information.
2736
Repo struct {
28-
Owner string
29-
Name string
37+
FullName string
38+
Namespace string
39+
Name string
3040
}
3141

3242
// Commit information.
@@ -48,8 +58,8 @@ type (
4858
Number int
4959
Status string
5060
Link string
51-
Started int64
52-
Finished int64
61+
Started float64
62+
Finished float64
5363
PR string
5464
DeployTo string
5565
}
@@ -83,6 +93,7 @@ type (
8393
Build Build
8494
Config Config
8595
Commit Commit
96+
GitHub GitHub
8697
}
8798

8899
// Audio format

plugin_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ func TestMissingUserConfig(t *testing.T) {
4444
func TestSendTextError(t *testing.T) {
4545
plugin := Plugin{
4646
Repo: Repo{
47-
Name: "go-hello",
48-
Owner: "appleboy",
47+
Name: "go-hello",
48+
FullName: "appleboy",
4949
},
5050
Commit: Commit{
5151
Author: "Bo-Yi Wu",
@@ -73,8 +73,8 @@ func TestSendTextError(t *testing.T) {
7373
func TestSendRoomAndGroup(t *testing.T) {
7474
plugin := Plugin{
7575
Repo: Repo{
76-
Name: "go-hello",
77-
Owner: "appleboy",
76+
Name: "go-hello",
77+
FullName: "appleboy",
7878
},
7979
Commit: Commit{
8080
Author: "Bo-Yi Wu",
@@ -103,8 +103,8 @@ func TestSendRoomAndGroup(t *testing.T) {
103103
func TestDefaultMessageFormat(t *testing.T) {
104104
plugin := Plugin{
105105
Repo: Repo{
106-
Name: "go-hello",
107-
Owner: "appleboy",
106+
Name: "go-hello",
107+
FullName: "appleboy",
108108
},
109109
Commit: Commit{
110110
Author: "Bo-Yi Wu",
@@ -126,8 +126,8 @@ func TestDefaultMessageFormat(t *testing.T) {
126126
func TestErrorSendMessage(t *testing.T) {
127127
plugin := Plugin{
128128
Repo: Repo{
129-
Name: "go-hello",
130-
Owner: "appleboy",
129+
Name: "go-hello",
130+
FullName: "appleboy",
131131
},
132132
Commit: Commit{
133133
Author: "Bo-Yi Wu",

0 commit comments

Comments
 (0)