Skip to content

Commit 957af0f

Browse files
authored
Merge pull request #89 from devatherock/workflow-name
feat: Included CircleCI workflow name in message
2 parents 33bafc5 + a1064ac commit 957af0f

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Changelog
22

33
## [Unreleased]
4+
### Added
5+
- [#78](https://github.com/devatherock/simple-slack/issues/78): Included CircleCI workflow name in message
6+
47
### Changed
58
- Used machine executor in deployment step
69
- Upgraded `flyctl` to `0.2.93`

cmd/app/app_integration_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ func TestSendNotificationWithBuildId(test *testing.T) {
4141
requestUrl = request.Host + request.URL.Path
4242
headers = request.Header
4343

44-
fmt.Fprintln(writer, `{"project_slug":"gh/devatherock/email-sender","pipeline_number":292,"status":"running"}`)
44+
fmt.Fprintln(writer, `{"name":"publish","project_slug":"gh/devatherock/email-sender","pipeline_number":292,"status":"running"}`)
4545
} else if requestIndex == 1 {
46-
fmt.Fprintln(writer, `{"project_slug":"gh/devatherock/email-sender","pipeline_number":292,"status":"success"}`)
46+
fmt.Fprintln(writer, `{"name":"publish","project_slug":"gh/devatherock/email-sender","pipeline_number":292,"status":"success"}`)
4747
} else if requestIndex == 4 {
48-
fmt.Fprintln(writer, `{"project_slug":"gh/devatherock/email-sender","pipeline_number":292,"status":"failed"}`)
48+
fmt.Fprintln(writer, `{"name":"publish","project_slug":"gh/devatherock/email-sender","pipeline_number":292,"status":"failed"}`)
4949
} else if requestIndex == 7 {
50-
fmt.Fprintln(writer, `{"project_slug":"gh/devatherock/email-sender","pipeline_number":292,"status":"failing"}`)
50+
fmt.Fprintln(writer, `{"name":"publish","project_slug":"gh/devatherock/email-sender","pipeline_number":292,"status":"failing"}`)
5151
} else { // 2, 5, 8 For the slack send call
5252
fmt.Fprintln(writer, `{"success":true}`)
5353
}
@@ -116,7 +116,7 @@ func TestSendNotificationWithBuildId(test *testing.T) {
116116

117117
// Verify slack request
118118
helper.VerifySlackRequest(test, capturedRequest, map[string]string{
119-
"text": fmt.Sprintf("%s: <https://app.circleci.com/pipelines/gh/devatherock/email-sender/292|gh/devatherock/email-sender-292>", data.expectedStatus),
119+
"text": fmt.Sprintf("%s: <https://app.circleci.com/pipelines/gh/devatherock/email-sender/292|gh/devatherock/email-sender-292>(publish)", data.expectedStatus),
120120
"color": data.expectedColor,
121121
"title": "Build completed",
122122
})

cmd/app/notifier.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ var exitStatuses = []string{"success", "failed", "failing"}
2323
var httpClient = &http.Client{}
2424

2525
type CircleCiWorkFlow struct {
26+
Name string `json:",omitempty"`
2627
Project string `json:"project_slug,omitempty"`
2728
Status string `json:",omitempty"`
2829
PipelineNumber int `json:"pipeline_number,omitempty"`
@@ -101,12 +102,13 @@ func monitor(buildId string, token string, slackRequest slack.SlackRequest) {
101102
if slices.Contains(exitStatuses, buildStatus) {
102103
if slackRequest.Text == "" {
103104
slackRequest.Text = fmt.Sprintf(
104-
"%s: <https://app.circleci.com/pipelines/%s/%d|%s-%d>",
105+
"%s: <https://app.circleci.com/pipelines/%s/%d|%s-%d>(%s)",
105106
strings.ToUpper(buildStatus[:1])+buildStatus[1:],
106107
circleCiWorkFlow.Project,
107108
circleCiWorkFlow.PipelineNumber,
108109
circleCiWorkFlow.Project,
109110
circleCiWorkFlow.PipelineNumber,
111+
circleCiWorkFlow.Name,
110112
)
111113
}
112114

0 commit comments

Comments
 (0)