From 1e1ca42a07086f9d507f048be0b87d14141305f8 Mon Sep 17 00:00:00 2001 From: hanjunlee Date: Mon, 10 May 2021 09:19:46 +0900 Subject: [PATCH] feat: add a new environment for the title of PR. --- environ/environ.go | 1 + environ/environ_test.go | 2 ++ 2 files changed, 3 insertions(+) diff --git a/environ/environ.go b/environ/environ.go index ab6147f..192e493 100644 --- a/environ/environ.go +++ b/environ/environ.go @@ -175,6 +175,7 @@ func Build(build *drone.Build) map[string]string { } if build.Event == drone.EventPullRequest { env["DRONE_PULL_REQUEST"] = re.FindString(build.Ref) + env["DRONE_PULL_REQUEST_TITLE"] = build.Title } if strings.HasPrefix(build.Ref, "refs/tags/") { tag := strings.TrimPrefix(build.Ref, "refs/tags/") diff --git a/environ/environ_test.go b/environ/environ_test.go index 9effacb..9f7996a 100644 --- a/environ/environ_test.go +++ b/environ/environ_test.go @@ -64,6 +64,7 @@ func TestBuild(t *testing.T) { Before: "7fd1a60b01f91b314f59955a4e4d4e80d8edf11d", Ref: "refs/pull/32/head", Link: "https://github.com/octocat/Hello-World/commit/762941318ee16e59dabbacb1b4049eec22f0d303", + Title: "feat: update README", Message: "updated README", Author: "octocat", AuthorAvatar: "https://avatars0.githubusercontent.com/u/583231", @@ -122,6 +123,7 @@ func TestBuild(t *testing.T) { "DRONE_DEPLOY_ID": "235634642", "DRONE_FAILED_STAGES": "frontend", "DRONE_PULL_REQUEST": "32", + "DRONE_PULL_REQUEST_TITLE": "feat: update README", "DRONE_SOURCE_BRANCH": "develop", "DRONE_TARGET_BRANCH": "master",