-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkestraflow.yaml
More file actions
95 lines (84 loc) · 3.31 KB
/
kestraflow.yaml
File metadata and controls
95 lines (84 loc) · 3.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
id: slack_invite
namespace: thisiskaransgit
inputs:
- id: user
type: BOOL
required: true
defaults: false
displayName: Are you interested in joining the Slack Workspace?
- id: name
type: STRING
required: false
defaults: John Doe
displayName: Please enter your name
dependsOn:
inputs:
- user
condition: "{{inputs.user}}"
tasks:
- id: decision
type: io.kestra.plugin.core.flow.Switch
value: "{{ inputs.user }}"
cases:
true:
- id: FetchIp
type: io.kestra.plugin.core.http.Request
uri: https://api.ipify.org
- id: GetCity
type: io.kestra.plugin.core.http.Request
uri: https://ipinfo.io/{{outputs.FetchIp.body}}?token={{secret('WHOCITY')}}
- id: TransformCity
type: io.kestra.plugin.transform.jsonata.TransformValue
from: "{{outputs.GetCity.body}}"
expression: $.city
- id: TransformAsn
type: io.kestra.plugin.transform.jsonata.TransformValue
from: "{{outputs.GetCity.body}}"
expression: $.org
- id: GetWeather
type: io.kestra.plugin.core.http.Request
uri: http://api.weatherstack.com/current?access_key={{secret('WHOWEATHER')}}&query={{outputs.TransformCity.value}}
- id: TransformWe
type: io.kestra.plugin.transform.jsonata.TransformValue
from: "{{outputs.GetWeather.body}}"
expression: |
$.location.localtime & "(localtime) ,from "& $.location.name & ", "
& $.location.region & " ("&
$.location.country &")" & "." &" Here's a quick weather report, today's weather is " &
$.current.weather_descriptions[0] & " with current conditions as follows temperature: " &
$.current.temperature & " degree Celcius" & " and humidity: " & $.current.humidity & "." & " The uv index is "& $.current.
(
$.current.uv_index < 3 ? "Low" :
$.current.uv_index < 6 ? "Moderate" :
"High"
)
- id: LogData
type: io.kestra.plugin.core.output.OutputValues
values:
deviceinfo: Your IP Address is {{outputs.FetchIp.body}} and your is asn is {{outputs.TransformAsn.value}}.
locateinfo: You accepted the invite on {{outputs.TransformWe.value}}
- id: invitelink
type: io.kestra.plugin.core.output.OutputValues
values:
msg: Here is the link {{inputs.name}}, a welcome message is waiting for you
link: https://join.slack.com/t/testingflow-group/shared_invite/{{secret('INVITED')}}
- id: send_slack_message
type: io.kestra.plugin.notifications.slack.SlackIncomingWebhook
url: https://hooks.slack.com/services/{{secret('WHOSLACK')}}
payload: |
{
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Welcome *{{inputs.name}}*, {{outputs.LogData.values.deviceinfo}} \n {{outputs.LogData.values.locateinfo}}"
}
}
]
}
false:
- id: exit
type: io.kestra.plugin.core.output.OutputValues
values:
msg: Sure, but we'll miss you ;)