Skip to content

Commit

Permalink
update pull request pr cicd
Browse files Browse the repository at this point in the history
  • Loading branch information
cruii committed Oct 12, 2023
1 parent 394ccda commit ae3b053
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 0 deletions.
12 changes: 12 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,16 @@ func main() {
Usage: "build failed steps",
EnvVar: "DRONE_FAILED_STEPS",
},
cli.StringFlag{
Name: "build.source_branch",
Usage: "build source branch",
EnvVar: "DRONE_SOURCE_BRANCH",
},
cli.StringFlag{
Name: "build.target_branch",
Usage: "build target branch",
EnvVar: "DRONE_TARGET_BRANCH",
},
}

if _, err := os.Stat("/run/drone/env"); err == nil {
Expand Down Expand Up @@ -208,6 +218,8 @@ func run(c *cli.Context) error {
CostTime: (c.Int64("build.finished") - c.Int64("build.started")) / 1000,
FailedStages: c.String("build.failed.stages"),
FailedSteps: c.String("build.failed.steps"),
TargetBranch: c.String("build.target_branch"),
SourceBranch: c.String("build.source_branch"),
},
Feishu: Feishu{
UserID: c.String("user_id"),
Expand Down
2 changes: 2 additions & 0 deletions plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ type (
CostTime int64
FailedStages string
FailedSteps string
SourceBranch string
TargetBranch string
}

CommitAuthor struct {
Expand Down
76 changes: 76 additions & 0 deletions template/compile_pr_success.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
{
"config": {
"wide_screen_mode": true
},
"elements": [
{
"fields": [
{
"is_short": true,
"text": {
"content": "**构建时间**\n{{ .Build.Started }}",
"tag": "lark_md"
}
},
{
"is_short": true,
"text": {
"content": "**仓库地址**\n[{{ .Repo.Owner}}/{{ .Repo.Name }}]({{ .Repo.Url }})\n",
"tag": "lark_md"
}
}
],
"tag": "div"
},
{
"tag": "markdown",
"content": "👨🏻‍💻 **Built by** [@{{ .Build.CommitAuthor.Username }}](https://github.com/{{ .Build.CommitAuthor.Username }})\n📌 **Pull Request**: \n{{ .Build.SourceBranch }} ➡️ {{ .Build.TargetBranch }}\n[{{ .Build.Pull }}]({{ .Repo.Url }}/pull/{{ .Build.Pull }}) {{ .Build.Pull.Title }}\n🖇️ **Commit**: [{{ .Build.Commit }}]({{ .Repo.Url }}/commit/{{ .Build.Commit }})\n📝 **Commit message**: {{ .Build.CommitMessage }}\n🛠️ **构建任务**: [#{{ .Build.Number }}]({{ .Build.Link }})\n⏱️ **构建耗时**: {{ .Build.CostTime }}s"
},
{
"tag": "action",
"actions": [
{
"tag": "button",
"text": {
"tag": "plain_text",
"content": "Merge PR"
},
"type": "primary",
"multi_url": {
"url": "https://open.feishu.cn/document",
"pc_url": "",
"android_url": "",
"ios_url": ""
}
},
{
"tag": "button",
"text": {
"tag": "plain_text",
"content": "Close PR"
},
"type": "danger"
}
]
},
{
"tag": "hr"
},
{
"elements": [
{
"content": "[来自未来ガジェット研究所](https://github.com/futuregadgetlabx)",
"tag": "lark_md"
}
],
"tag": "note"
}
],
"header": {
"template": "green",
"title": {
"content": "🎉【Drone CI】代码编译成功",
"tag": "plain_text"
}
}
}

0 comments on commit ae3b053

Please sign in to comment.