fastlane-plugin-teams_card 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 004e2184713ea84f86cc692dfc410fa7594666d0df1799489f8ae65c8b53af12
|
4
|
+
data.tar.gz: be00886172de69b8adc03463eeaf5e6a44a3d0d881abb707330a64690e0b1127
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 25aa6b60c75cff9e11d3ba36331589748f267e3c55733c5f2b41eecdfd6ce30a7ddad12cbfa9f24df4c4188b380afb44a4df40e81417daceb2e9a33dc8bddf19
|
7
|
+
data.tar.gz: c4c2e5436e6e949ce2f02ce59ede445215094d8577f4671e1d3dbcf42e9a50acc61f20637d8cd5840ad5cc7b993afdfbc73ec2736cc8db678da6d65e813f3c66
|
data/README.md
CHANGED
@@ -1,7 +1,9 @@
|
|
1
|
-
# teams_card plugin
|
1
|
+
# Microsoft Teams fastlane teams_card plugin via Workflow
|
2
2
|
|
3
3
|
[](https://rubygems.org/gems/fastlane-plugin-teams_card)
|
4
4
|
|
5
|
+
> ⚠️ Note: This plugin utilizes the latest **Workflows** app (rather than the [now-retired Office connectors](https://devblogs.microsoft.com/microsoft365dev/retirement-of-office-365-connectors-within-microsoft-teams/) used in other plugins)
|
6
|
+
|
5
7
|
## Getting Started
|
6
8
|
|
7
9
|
This project is a [_fastlane_](https://github.com/fastlane/fastlane) plugin. To get started with `fastlane-plugin-teams_card`, add it to your project by running:
|
@@ -69,9 +71,9 @@ fastlane action teams_card
|
|
69
71
|
|
70
72
|
| Key | Description | Env Var(s) | Default |
|
71
73
|
|-------------|----------------------------------------------------|---------------------------|---------|
|
72
|
-
| `title` |
|
73
|
-
| `image` |
|
74
|
-
| `image_title` |
|
74
|
+
| `title` | Optional title | `TEAMS_MESSAGE_TITLE` | |
|
75
|
+
| `image` | Optional image on your activity (project logo, company logo, etc.) | `TEAMS_MESSAGE_IMAGE` | |
|
76
|
+
| `image_title` | Optional title next to your image | `TEAMS_MESSAGE_IMAGE_TITLE` | |
|
75
77
|
| `text` | The message you want to display | `TEAMS_MESSAGE_TEXT` | |
|
76
78
|
| `facts` | Optional facts (assigned to, due date, status, branch, environment, etc.) | `TEAMS_MESSAGE_FACTS` | `[]` |
|
77
79
|
| `open_url` | Optional URL for a button at the bottom of the card | `TEAMS_MESSAGE_OPEN_URL` | |
|
@@ -6,6 +6,12 @@ module Fastlane
|
|
6
6
|
module Actions
|
7
7
|
class TeamsCardAction < Action
|
8
8
|
def self.run(params)
|
9
|
+
payload = build_payload(params)
|
10
|
+
send_message(params[:workflow_url], payload)
|
11
|
+
end
|
12
|
+
|
13
|
+
# Build the payload for the Teams message
|
14
|
+
def self.build_payload(params)
|
9
15
|
payload = {
|
10
16
|
"type" => "message",
|
11
17
|
"attachments" => [{
|
@@ -13,84 +19,104 @@ module Fastlane
|
|
13
19
|
"contentUrl" => nil,
|
14
20
|
"content" => {
|
15
21
|
"type" => "AdaptiveCard",
|
16
|
-
"body" =>
|
17
|
-
{
|
18
|
-
"type" => "TextBlock",
|
19
|
-
"text" => params[:text],
|
20
|
-
"wrap" => true
|
21
|
-
},
|
22
|
-
{
|
23
|
-
"type" => "FactSet",
|
24
|
-
"facts" => params[:facts]
|
25
|
-
}
|
26
|
-
],
|
22
|
+
"body" => build_card_body(params),
|
27
23
|
"$schema" => "http://adaptivecards.io/schemas/adaptive-card.json",
|
28
24
|
"version" => "1.2"
|
29
25
|
}
|
30
26
|
}]
|
31
27
|
}
|
32
28
|
|
33
|
-
|
34
|
-
|
29
|
+
add_actions_to_payload(payload, params[:open_url]) if params[:open_url]
|
30
|
+
payload
|
31
|
+
end
|
32
|
+
|
33
|
+
# Construct the body of the Adaptive Card
|
34
|
+
def self.build_card_body(params)
|
35
|
+
body = [
|
36
|
+
build_text_block(params[:text]),
|
37
|
+
build_fact_set(params[:facts])
|
38
|
+
]
|
39
|
+
|
40
|
+
body.unshift(build_image_column_set(params[:image], params[:image_title])) if params[:image] || params[:image_title]
|
41
|
+
body.unshift(build_title_block(params[:title])) if params[:title]
|
42
|
+
body
|
43
|
+
end
|
44
|
+
|
45
|
+
# Create a text block for the card
|
46
|
+
def self.build_text_block(text)
|
47
|
+
{
|
48
|
+
"type" => "TextBlock",
|
49
|
+
"text" => text,
|
50
|
+
"wrap" => true
|
51
|
+
}
|
52
|
+
end
|
53
|
+
|
54
|
+
# Create a fact set for the card
|
55
|
+
def self.build_fact_set(facts)
|
56
|
+
{
|
57
|
+
"type" => "FactSet",
|
58
|
+
"facts" => facts
|
59
|
+
}
|
60
|
+
end
|
61
|
+
|
62
|
+
# Create an image and title column set for the card
|
63
|
+
def self.build_image_column_set(image, image_title)
|
64
|
+
{
|
65
|
+
"type" => "ColumnSet",
|
66
|
+
"columns" => [
|
35
67
|
{
|
36
|
-
"type" => "
|
37
|
-
"
|
38
|
-
{
|
39
|
-
"type" => "Column",
|
40
|
-
"items" => [
|
41
|
-
{
|
42
|
-
"type" => "Image",
|
43
|
-
"style" => "Person",
|
44
|
-
"url" => params[:image],
|
45
|
-
"size" => "Small"
|
46
|
-
}
|
47
|
-
],
|
48
|
-
"width" => "auto"
|
49
|
-
},
|
68
|
+
"type" => "Column",
|
69
|
+
"items" => [
|
50
70
|
{
|
51
|
-
"type" => "
|
52
|
-
"
|
53
|
-
|
54
|
-
|
55
|
-
"weight" => "Bolder",
|
56
|
-
"text" => params[:image_title],
|
57
|
-
"wrap" => true
|
58
|
-
}
|
59
|
-
],
|
60
|
-
"width" => "stretch",
|
61
|
-
"horizontalAlignment" => "Left",
|
62
|
-
"verticalContentAlignment" => "Center"
|
71
|
+
"type" => "Image",
|
72
|
+
"style" => "Person",
|
73
|
+
"url" => image,
|
74
|
+
"size" => "Small"
|
63
75
|
}
|
64
|
-
]
|
65
|
-
|
66
|
-
|
67
|
-
end
|
68
|
-
|
69
|
-
if params[:title]
|
70
|
-
payload["attachments"][0]["content"]["body"].unshift(
|
71
|
-
{
|
72
|
-
"type" => "TextBlock",
|
73
|
-
"size" => "large",
|
74
|
-
"weight" => "bolder",
|
75
|
-
"text" => params[:title],
|
76
|
-
"wrap" => true
|
77
|
-
}
|
78
|
-
)
|
79
|
-
end
|
80
|
-
|
81
|
-
if params[:open_url]
|
82
|
-
payload["attachments"][0]["content"]["actions"] = [
|
76
|
+
],
|
77
|
+
"width" => "auto"
|
78
|
+
},
|
83
79
|
{
|
84
|
-
"type" => "
|
85
|
-
"
|
86
|
-
|
80
|
+
"type" => "Column",
|
81
|
+
"items" => [
|
82
|
+
{
|
83
|
+
"type" => "TextBlock",
|
84
|
+
"weight" => "Bolder",
|
85
|
+
"text" => image_title,
|
86
|
+
"wrap" => true
|
87
|
+
}
|
88
|
+
],
|
89
|
+
"width" => "stretch",
|
90
|
+
"horizontalAlignment" => "Left",
|
91
|
+
"verticalContentAlignment" => "Center"
|
87
92
|
}
|
88
93
|
]
|
89
|
-
|
94
|
+
}
|
95
|
+
end
|
90
96
|
|
91
|
-
|
97
|
+
# Create a title block for the card
|
98
|
+
def self.build_title_block(title)
|
99
|
+
{
|
100
|
+
"type" => "TextBlock",
|
101
|
+
"size" => "large",
|
102
|
+
"weight" => "bolder",
|
103
|
+
"text" => title,
|
104
|
+
"wrap" => true
|
105
|
+
}
|
106
|
+
end
|
107
|
+
|
108
|
+
# Add actions to the payload if needed
|
109
|
+
def self.add_actions_to_payload(payload, open_url)
|
110
|
+
payload["attachments"][0]["content"]["actions"] = [
|
111
|
+
{
|
112
|
+
"type" => "Action.OpenUrl",
|
113
|
+
"title" => "Open",
|
114
|
+
"url" => open_url
|
115
|
+
}
|
116
|
+
]
|
92
117
|
end
|
93
118
|
|
119
|
+
# Send the message to the Teams Webhook URL
|
94
120
|
def self.send_message(url, payload)
|
95
121
|
require 'net/http'
|
96
122
|
require 'uri'
|
@@ -104,6 +130,7 @@ module Fastlane
|
|
104
130
|
is_message_success(response)
|
105
131
|
end
|
106
132
|
|
133
|
+
# Check if the message was successfully posted
|
107
134
|
def self.is_message_success(response)
|
108
135
|
if response.code.to_i == 202
|
109
136
|
UI.message("🔔 The card was posted successfully.")
|