Skip to content

Commit

Permalink
Merge branch 'master' into feature/2.0.0-bump
Browse files Browse the repository at this point in the history
  • Loading branch information
jamieastley committed Feb 28, 2021
2 parents cd13637 + 930f3d2 commit e885ffe
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 26 deletions.
8 changes: 4 additions & 4 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ type config struct {
SectionSubtitle string `env:"section_subtitle"`
SectionText string `env:"section_text"`
SectionHeaderImage string `env:"section_header_image"`
EnablePrimarySectionMarkdown bool `env:"enable_primary_section_markdown"`
EnableBuildFactsMarkdown bool `env:"enable_build_status_facts_markdown"`
EnableDefaultActions bool `env:"enable_default_actions"`
EnableDebug bool `env:"enable_debug"`
EnablePrimarySectionMarkdown string `env:"enable_primary_section_markdown"`
EnableBuildFactsMarkdown string `env:"enable_build_status_facts_markdown"`
EnableDefaultActions string `env:"enable_default_actions"`
EnableDebug string `env:"enable_debug"`
RepoURL string `env:"repository_url"`
Actions string `env:"actions"`
}
12 changes: 8 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ func optionalUserValue(defaultValue, userValue string) string {
return userValue
}

func valueOptionToBool(userValue string) bool {
return userValue == "yes"
}

func newMessage(cfg config, buildSuccessful bool) Message {
message := Message{}
message.Type = "MessageCard"
Expand All @@ -52,7 +56,7 @@ func newMessage(cfg config, buildSuccessful bool) Message {

// MessageCard Actions
actions := []OpenURIAction{}
if cfg.EnableDefaultActions {
if valueOptionToBool(cfg.EnableDefaultActions) {
goToRepoAction := buildURIAction(Action{
Text: "Go To Repo",
Targets: []ActionTarget{
Expand Down Expand Up @@ -87,7 +91,7 @@ func buildPrimarySection(cfg config) Section {
section.ActivitySubtitle = cfg.SectionSubtitle
section.Text = cfg.SectionText
section.ActivityImage = cfg.SectionHeaderImage
section.Markdown = cfg.EnablePrimarySectionMarkdown
section.Markdown = valueOptionToBool(cfg.EnablePrimarySectionMarkdown)
return section
}

Expand Down Expand Up @@ -129,7 +133,7 @@ func buildFactsSection(cfg config, buildSuccessful bool) Section {
}

return Section{
Markdown: cfg.EnableBuildFactsMarkdown,
Markdown: valueOptionToBool(cfg.EnableBuildFactsMarkdown),
Facts: []Fact{buildStatusFact, buildNumberFact, buildBranchFact, buildTimeFact, workflowFact},
}
}
Expand Down Expand Up @@ -191,7 +195,7 @@ func main() {
stepconf.Print(cfg)

message := newMessage(cfg, buildSucceeded)
if err := postMessage(cfg.WebhookURL, message, cfg.EnableDebug); err != nil {
if err := postMessage(cfg.WebhookURL, message, valueOptionToBool(cfg.EnableDebug)); err != nil {
fmt.Println(fmt.Sprintf("Error: %s", err))
os.Exit(1)
}
Expand Down
22 changes: 11 additions & 11 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ var mockConfig = config{
SectionSubtitle: "Commit message",
SectionText: "Commit message body",
SectionHeaderImage: "",
EnablePrimarySectionMarkdown: false,
EnableBuildFactsMarkdown: false,
EnableDefaultActions: true,
EnableDebug: false,
EnablePrimarySectionMarkdown: "no",
EnableBuildFactsMarkdown: "no",
EnableDefaultActions: "yes",
EnableDebug: "no",
RepoURL: "https://www.github.com/username/repo",
Actions: `[
{
Expand Down Expand Up @@ -86,7 +86,7 @@ func TestBuildPrimarySection(t *testing.T) {
SectionTitle: "Some author",
SectionSubtitle: "A commit message",
SectionText: "The commits message body",
EnablePrimarySectionMarkdown: false,
EnablePrimarySectionMarkdown: "no",
}
var tests = []struct {
input config
Expand All @@ -98,7 +98,7 @@ func TestBuildPrimarySection(t *testing.T) {
ActivityTitle: defaultValuesConfig.SectionTitle,
ActivitySubtitle: defaultValuesConfig.SectionSubtitle,
Text: defaultValuesConfig.SectionText,
Markdown: defaultValuesConfig.EnablePrimarySectionMarkdown,
Markdown: valueOptionToBool(defaultValuesConfig.EnablePrimarySectionMarkdown),
},
},
}
Expand All @@ -122,7 +122,7 @@ func TestBuildFactsSection(t *testing.T) {
mockConfig,
true,
Section{
Markdown: mockConfig.EnableBuildFactsMarkdown,
Markdown: valueOptionToBool(mockConfig.EnableBuildFactsMarkdown),
Facts: []Fact{
{
Name: "Build Status",
Expand Down Expand Up @@ -152,7 +152,7 @@ func TestBuildFactsSection(t *testing.T) {
mockConfig,
false,
Section{
Markdown: mockConfig.EnableBuildFactsMarkdown,
Markdown: valueOptionToBool(mockConfig.EnableBuildFactsMarkdown),
Facts: []Fact{
{
Name: "Build Status",
Expand Down Expand Up @@ -210,7 +210,7 @@ func TestNewMessage(t *testing.T) {
Value: mockConfig.Workflow,
},
},
Markdown: mockConfig.EnableBuildFactsMarkdown,
Markdown: valueOptionToBool(mockConfig.EnableBuildFactsMarkdown),
HeroImage: HeroImage{},
}

Expand All @@ -237,15 +237,15 @@ func TestNewMessage(t *testing.T) {
Value: mockConfig.Workflow,
},
},
Markdown: mockConfig.EnableBuildFactsMarkdown,
Markdown: valueOptionToBool(mockConfig.EnableBuildFactsMarkdown),
HeroImage: HeroImage{},
}

var primarySection = Section{
ActivityTitle: mockConfig.SectionTitle,
ActivitySubtitle: mockConfig.SectionSubtitle,
ActivityImage: mockConfig.SectionHeaderImage,
Markdown: mockConfig.EnablePrimarySectionMarkdown,
Markdown: valueOptionToBool(mockConfig.EnablePrimarySectionMarkdown),
Text: mockConfig.SectionText,
HeroImage: HeroImage{},
}
Expand Down
26 changes: 19 additions & 7 deletions step.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Microsoft Teams Integration
summary: Allows you to recieve build status updates on Microsoft Team using Incoming Webhooks
summary: Allows you to receive build status updates on Microsoft Team using Incoming Webhooks
description: |
Uses Incoming Webhooks feature in Microsft Teams to send updates on your builds
website: https://github.com/amrfarid140/bitrise-step-microsoft-teams-integration
Expand Down Expand Up @@ -29,14 +29,17 @@ inputs:
If no value is given, the default value will be the `BITRISE_APP_TITLE`.
- enable_debug: false
- enable_debug: "no"
opts:
title: "Enable debug logging"
summary: "Toggles whether to log debug info to the build output"
description: |
Enables debug logging to the Bitrise console.
WARNING: This will output the JSON value of the Teams Webhook body, be mindful of what is output here.
value_options:
- "yes"
- "no"

- success_theme_color: 359914
opts:
Expand All @@ -58,7 +61,7 @@ inputs:
Defaults to `E04504` if not overridden.
- enable_primary_section_markdown: true
- enable_primary_section_markdown: "yes"
opts:
category: "Markdown Rules"
title: "Primary Section Markdown"
Expand All @@ -70,8 +73,11 @@ inputs:
* section_title
* section_subtitle
* section_text
value_options:
- "yes"
- "no"

- enable_build_status_facts_markdown: false
- enable_build_status_facts_markdown: "no"
opts:
category: "Markdown Rules"
title: "Build Status Facts Markdown"
Expand All @@ -85,6 +91,9 @@ inputs:
* Git Branch
* Build Triggered
* Workflow
value_options:
- "yes"
- "no"

- section_title: $GIT_CLONE_COMMIT_AUTHOR_NAME
opts:
Expand Down Expand Up @@ -116,22 +125,25 @@ inputs:
this will be set to the commit message body that triggered the build.
If desired, this is the perfect place to include release notes via the `generate-changelog` Bitrise step, however
setting `enable_primary_section_markdown` to `true` may be necessary to properly format the changelog content.
setting `enable_primary_section_markdown` to `yes` may be necessary to properly format the changelog content.
- section_header_image:
opts:
category: "MessageCard Content"
title: "Section Image"
summary: "Image that is displayed within the MessageCard Section `activityImage`"

- enable_default_actions: true
- enable_default_actions: "yes"
opts:
category: "MessageCard Actions"
title: "Default MessageCard Actions"
summary: "Toggles the default actions within the MessageCard."
description: |
Allows for disabling the default 'Go To Repo' and 'Go To Build' MessageCard Actions if you wish to provide only your own custom actions
via the `actions` step input (up to a limit of 4 actions in total).
value_options:
- "yes"
- "no"

- actions: "[]"
opts:
Expand All @@ -142,7 +154,7 @@ inputs:
A stringified JSON object array of additional custom actions to display on the card.
The maximum amount of actions a single card can display is 4, 2 of which are used if
`enable_default_actions` is set to `true`.
`enable_default_actions` is set to `yes`.
Each action button object must have a `text` key/value pair, and a list of `target` objects
which define the `uri`, specific to which platform-client (`os` value) the Teams message is viewed on.
Expand Down

0 comments on commit e885ffe

Please sign in to comment.