fastlane-plugin-teams_card 0.1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: c45da79cee6983b8b2a4c7ab3bbf9263ac8a8b00071c9919e2226d035d35ad18
4
+ data.tar.gz: 878329a865a503a026a233fa2d6bfddc69bee8bb063cbe3de24f96753e442014
5
+ SHA512:
6
+ metadata.gz: 4ed16d47c6d852f46c6c792bf90f2a3fd5ac31893c114f5070e305bed8f8c6be763753dc6cb17a96393665d4c822de5cff3b2af5db6016ed42003c2cdaa50c2a
7
+ data.tar.gz: fe69ef1add0f62c4ab7d94eec7633d4b0bd9b2449c7208b8a467f6dccc8cf8f9ad3ee5eeaa6c35ecd688c15b2bf3635bb830790fc70f3d256f3bb5b556a6252a
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2024 Kondamon
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,101 @@
1
+ # teams_card plugin
2
+
3
+ [![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-teams_card)
4
+
5
+ ## Getting Started
6
+
7
+ 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:
8
+
9
+ ```bash
10
+ fastlane add_plugin teams_card
11
+ ```
12
+
13
+ ## About teams_card
14
+
15
+ With this plugin you will be able to send a message on a microsoft teams channel, group chat or chat.
16
+
17
+ Beforehand you must Set up an incoming webhook workflow from a template in Microsoft Teams channel of your choice. You can follow this documentation to help you do this: [Incoming Webhook](https://support.microsoft.com/en-us/office/create-incoming-webhooks-with-workflows-for-microsoft-teams-8ae491c7-0394-4861-ba59-055e33f75498)
18
+
19
+ `teams_card` allows you to send a fully custom message to a specific incoming webhook.
20
+
21
+ ## Usage
22
+
23
+ ```ruby
24
+ teams_card(
25
+ workflow_url: 'https://your.logic.azure.com:443/workflows/1234567890',
26
+ text: 'A new release is ready for testing!',
27
+ image: 'https://raw.githubusercontent.com/fastlane/boarding/master/app/assets/images/fastlane.png',
28
+ image_title: 'Fastlane',
29
+ ]
30
+ )
31
+ ```
32
+
33
+ or
34
+
35
+ ```ruby
36
+ teams_card(
37
+ workflow_url: 'https://your.logic.azure.com:443/workflows/1234567890',
38
+ title: 'Notification Title',
39
+ text: 'A new release is ready for testing!',
40
+ image: 'https://raw.githubusercontent.com/fastlane/boarding/master/app/assets/images/fastlane.png',
41
+ image_title: 'Fastlane',
42
+ open_url: 'https://beta.itunes.apple.com/v1/app/_YOUR_APP_ID_',
43
+ facts: [
44
+ {
45
+ 'title' => 'Environment',
46
+ 'value' => 'Staging'
47
+ },
48
+ {
49
+ 'title' => 'Release',
50
+ 'value' => '1.0.3'
51
+ }
52
+ ]
53
+ )
54
+ ```
55
+
56
+ This code give the following message:
57
+
58
+ <img src="screenshots/1.png">
59
+
60
+ ### Help
61
+
62
+ Once installed, information and help for an action can be printed out with this command:
63
+
64
+ ```bash
65
+ fastlane action teams_card
66
+ ```
67
+
68
+ ### `teams_card`
69
+
70
+ | Key | Description | Env Var(s) | Default |
71
+ |-------------|----------------------------------------------------|---------------------------|---------|
72
+ | `title` | The title that should be displayed on Teams | `TEAMS_MESSAGE_TITLE` | |
73
+ | `image` | Displays an image on your activity (project logo, company logo, etc.) | `TEAMS_MESSAGE_IMAGE` | |
74
+ | `image_title` | Displays a title next to your image | `TEAMS_MESSAGE_IMAGE_TITLE` | |
75
+ | `text` | The message you want to display | `TEAMS_MESSAGE_TEXT` | |
76
+ | `facts` | Optional facts (assigned to, due date, status, branch, environment, etc.) | `TEAMS_MESSAGE_FACTS` | `[]` |
77
+ | `open_url` | Optional URL for a button at the bottom of the card | `TEAMS_MESSAGE_OPEN_URL` | |
78
+ | `workflow_url` | The URL of the incoming Webhook you created in Workflows app | `TEAMS_MESSAGE_WORKFLOW_URL` | |
79
+
80
+
81
+ ## Example
82
+
83
+ Check out the [example `Fastfile`](fastlane/Fastfile) to see how to use this plugin. Try it by cloning the repo, running `fastlane install_plugins` and `bundle exec fastlane test`.
84
+
85
+ **Note to author:** Please set up a sample project to make it easy for users to explore what your plugin does. Provide everything that is necessary to try out the plugin in this project (including a sample Xcode/Android project if necessary)
86
+
87
+ ## Issues and Feedback
88
+
89
+ For any other issues and feedback about this plugin, please submit it to this repository.
90
+
91
+ ## Troubleshooting
92
+
93
+ If you have trouble using plugins, check out the [Plugins Troubleshooting](https://docs.fastlane.tools/plugins/plugins-troubleshooting/) guide.
94
+
95
+ ## Using _fastlane_ Plugins
96
+
97
+ For more information about how the `fastlane` plugin system works, check out the [Plugins documentation](https://docs.fastlane.tools/plugins/create-plugin/).
98
+
99
+ ## About _fastlane_
100
+
101
+ _fastlane_ is the easiest way to automate beta deployments and releases for your iOS and Android apps. To learn more, check out [fastlane.tools](https://fastlane.tools).
@@ -0,0 +1,205 @@
1
+ require 'fastlane/action'
2
+ require 'fastlane_core'
3
+ require_relative '../helper/teams_card_helper'
4
+
5
+ module Fastlane
6
+ module Actions
7
+ class TeamsCardAction < Action
8
+ def self.run(params)
9
+ payload = {
10
+ "type" => "message",
11
+ "attachments" => [{
12
+ "contentType" => "application/vnd.microsoft.card.adaptive",
13
+ "contentUrl" => nil,
14
+ "content" => {
15
+ "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
+ ],
27
+ "$schema" => "http://adaptivecards.io/schemas/adaptive-card.json",
28
+ "version" => "1.2"
29
+ }
30
+ }]
31
+ }
32
+
33
+ if params[:image] || params[:image_title]
34
+ payload["attachments"][0]["content"]["body"].unshift(
35
+ {
36
+ "type" => "ColumnSet",
37
+ "columns" => [
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
+ },
50
+ {
51
+ "type" => "Column",
52
+ "items" => [
53
+ {
54
+ "type" => "TextBlock",
55
+ "weight" => "Bolder",
56
+ "text" => params[:image_title],
57
+ "wrap" => true
58
+ }
59
+ ],
60
+ "width" => "stretch",
61
+ "horizontalAlignment" => "Left",
62
+ "verticalContentAlignment" => "Center"
63
+ }
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"] = [
83
+ {
84
+ "type" => "Action.OpenUrl",
85
+ "title" => "Open",
86
+ "url" => params[:open_url]
87
+ }
88
+ ]
89
+ end
90
+
91
+ send_message(params[:workflow_url], payload)
92
+ end
93
+
94
+ def self.send_message(url, payload)
95
+ require 'net/http'
96
+ require 'uri'
97
+ json_headers = { 'Content-Type' => 'application/json' }
98
+ uri = URI.parse(url)
99
+ http = Net::HTTP.new(uri.host, uri.port)
100
+ http.use_ssl = true
101
+ request = Net::HTTP::Post.new(uri.request_uri, json_headers)
102
+ request.body = payload.to_json
103
+ response = http.request(request)
104
+ is_message_success(response)
105
+ end
106
+
107
+ def self.is_message_success(response)
108
+ if response.code.to_i == 202
109
+ UI.message("🔔 The card was posted successfully.")
110
+ true
111
+ else
112
+ UI.user_error!("⚠️ An error occurred: #{response.body}")
113
+ end
114
+ end
115
+
116
+ def self.available_options
117
+ [
118
+ FastlaneCore::ConfigItem.new(key: :title,
119
+ env_name: "TEAMS_MESSAGE_TITLE",
120
+ optional: true,
121
+ description: "The title that should be displayed on Teams"),
122
+
123
+ FastlaneCore::ConfigItem.new(key: :image,
124
+ env_name: "TEAMS_MESSAGE_IMAGE",
125
+ sensitive: true,
126
+ optional: true,
127
+ description: "Displays an image on your activity (project logo, company logo, ...)"),
128
+
129
+ FastlaneCore::ConfigItem.new(key: :image_title,
130
+ env_name: "TEAMS_MESSAGE_IMAGE_TITLE",
131
+ optional: true,
132
+ description: "Displays a title next to your image"),
133
+
134
+ FastlaneCore::ConfigItem.new(key: :text,
135
+ env_name: "TEAMS_MESSAGE_TEXT",
136
+ description: "The message you want to display",
137
+ optional: false),
138
+
139
+ FastlaneCore::ConfigItem.new(key: :facts,
140
+ type: Array,
141
+ env_name: "TEAMS_MESSAGE_FACTS",
142
+ description: "Optional facts (assigned to, due date, status, branch, environment, ...)",
143
+ default_value: []),
144
+
145
+ FastlaneCore::ConfigItem.new(key: :open_url,
146
+ env_name: "TEAMS_MESSAGE_OPEN_URL",
147
+ description: "Optional url for a button at bottom of card",
148
+ optional: true),
149
+
150
+ FastlaneCore::ConfigItem.new(key: :workflow_url,
151
+ env_name: "TEAMS_MESSAGE_TEAMS_URL",
152
+ sensitive: true,
153
+ optional: false,
154
+ description: "The URL of the incoming Webhook you created on your Microsoft Teams channel",
155
+ verify_block: proc do |value|
156
+ UI.user_error!("Invalid URL, must start with https://") unless value.start_with?("https://")
157
+ end)
158
+ ]
159
+ end
160
+
161
+ def self.example_code
162
+ [
163
+ 'teams_card(
164
+ workflow_url: "https://your.logic.azure.com:443/workflows/1234567890",
165
+ title: "Notification Title",
166
+ text: "A new release is ready for testing!",
167
+ image: "https://raw.githubusercontent.com/fastlane/boarding/master/app/assets/images/fastlane.png",
168
+ image_title: "Fastlane",
169
+ open_url: "https://beta.itunes.apple.com/v1/app/_YOUR_APP_ID_",
170
+ facts: [
171
+ {
172
+ "title" => "Environment",
173
+ "value" => "Staging"
174
+ },
175
+ {
176
+ "title" => "Release",
177
+ "value" => "1.0.3"
178
+ }
179
+ ]
180
+ )'
181
+ ]
182
+ end
183
+
184
+ def self.description
185
+ "Easily send a message to a Microsoft Teams channel or group chat through the Power Automate Webhook connector"
186
+ end
187
+
188
+ def self.details
189
+ "Send a message to a specific channel, group chat or chat on your Microsoft Teams organization via a Workflow of Power Automate"
190
+ end
191
+
192
+ def self.authors
193
+ ["Kondamon"]
194
+ end
195
+
196
+ def self.return_value
197
+ # If your method provides a return value, you can describe here what it does
198
+ end
199
+
200
+ def self.is_supported?(platform)
201
+ true
202
+ end
203
+ end
204
+ end
205
+ end
@@ -0,0 +1,16 @@
1
+ require 'fastlane_core/ui/ui'
2
+
3
+ module Fastlane
4
+ UI = FastlaneCore::UI unless Fastlane.const_defined?(:UI)
5
+
6
+ module Helper
7
+ class TeamsCardHelper
8
+ # class methods that you define here become available in your action
9
+ # as `Helper::TeamsCardHelper.your_method`
10
+ #
11
+ def self.show_message
12
+ UI.message("Hello from the teams_card plugin helper!")
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,5 @@
1
+ module Fastlane
2
+ module TeamsCard
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,16 @@
1
+ require 'fastlane/plugin/teams_card/version'
2
+
3
+ module Fastlane
4
+ module TeamsCard
5
+ # Return all .rb files inside the "actions" and "helper" directory
6
+ def self.all_classes
7
+ Dir[File.expand_path('**/{actions,helper}/*.rb', File.dirname(__FILE__))]
8
+ end
9
+ end
10
+ end
11
+
12
+ # By default we want to import all available actions and helpers
13
+ # A plugin can contain any number of actions and plugins
14
+ Fastlane::TeamsCard.all_classes.each do |current|
15
+ require current
16
+ end
metadata ADDED
@@ -0,0 +1,49 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fastlane-plugin-teams_card
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Kondamon
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2024-08-31 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email:
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - LICENSE
20
+ - README.md
21
+ - lib/fastlane/plugin/teams_card.rb
22
+ - lib/fastlane/plugin/teams_card/actions/teams_card_action.rb
23
+ - lib/fastlane/plugin/teams_card/helper/teams_card_helper.rb
24
+ - lib/fastlane/plugin/teams_card/version.rb
25
+ homepage: https://github.com/Kondamon/fastlane-plugin-teams_card
26
+ licenses:
27
+ - MIT
28
+ metadata:
29
+ rubygems_mfa_required: 'true'
30
+ post_install_message:
31
+ rdoc_options: []
32
+ require_paths:
33
+ - lib
34
+ required_ruby_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: '2.6'
39
+ required_rubygems_version: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ requirements: []
45
+ rubygems_version: 3.2.33
46
+ signing_key:
47
+ specification_version: 4
48
+ summary: Easily alert a Microsoft Teams channel, group chat or chat via Workflows
49
+ test_files: []