Skip to content

Commit

Permalink
Merge pull request #10 from PeyGis/windmill-trigger
Browse files Browse the repository at this point in the history
trigger windmill job using action
  • Loading branch information
yonabogu authored Nov 21, 2023
2 parents 0b30565 + 5690434 commit 9bee619
Showing 1 changed file with 154 additions and 0 deletions.
154 changes: 154 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -341,3 +341,157 @@ helm install my-port-agent port-labs/port-agent \
--set env.secret.CIRCLE_CI_TOKEN=YOUR_CIRCLE_CI_PERSONAL_TOKEN \
--set-file controlThePayloadConfig=./invocations.json
```

#### Windmill

This example helps internal developer teams to trigger [Windmill](https://www.windmill.dev) job using Port's self service actions. In particular, you will create a blueprint for `windmillJob` that will be connected to a backend action. You will then add some configuration files (`invocations.json`) to control the payload and trigger your Windmill job directly from Port.


Create the following blueprint, action and mapping to trigger a Windmill job.

<details>
<summary>Blueprint</summary>

```json
{
"identifier": "windmillJob",
"description": "This blueprint represents a windmill job in our software catalog",
"title": "Windmill",
"icon": "DefaultProperty",
"schema": {
"properties": {
"workspace": {
"type": "string",
"title": "Workspace"
},
"path": {
"type": "string",
"title": "File Path"
},
"trigerredBy": {
"type": "string",
"title": "Triggered By",
"format": "user"
},
"createdAt": {
"type": "string",
"format": "date-time",
"title": "Created At"
}
},
"required": []
},
"mirrorProperties": {},
"calculationProperties": {},
"relations": {}
}
```
</details>

<details>
<summary>Action</summary>

```json
[
{
"identifier":"trigger_windmill_pipeline",
"title":"Trigger Windmill Pipeline",
"icon":"DefaultProperty",
"userInputs":{
"properties":{
"workspace":{
"title":"Workspace",
"description":"The Workspace identifier",
"type":"string"
},
"file_path":{
"title":"File Path",
"description":"The path of the job script in the workspace, including the /u and /f prefix",
"type":"string"
},
"job_data":{
"title":"Job Data",
"description":"The data to be passed to the job in order to execute successfully",
"type":"object"
}
},
"required":[
"workspace",
"file_path",
"job_data"
],
"order":[
"workspace",
"file_path",
"job_data"
]
},
"invocationMethod":{
"type":"WEBHOOK",
"agent":true,
"synchronized":false,
"method":"POST",
"url":"https://app.windmill.dev/api"
},
"trigger":"CREATE",
"requiredApproval":false
}
]
```
</details>

<details>
<summary>Mapping - (Should be saved as `invocations.json`)</summary>

```json
[
{
"enabled": ".action == \"trigger_windmill_pipeline\"",
"url": "\"https://app.windmill.dev\" as $baseUrl | .payload.properties.workspace as $workspace | .payload.properties.file_path as $path | $baseUrl + \"/api/w/\" + $workspace + \"/jobs/run_wait_result/f/\" + $path",
"headers": {
"Authorization": "\"Bearer \" + env.WINDMILL_TOKEN",
"Content-Type": "\"application/json\""
},
"body": ".payload.properties.job_data"
}
]
```
</details>

**Port agent installation for Windmill example**:

```sh
helm repo add port-labs https://port-labs.github.io/helm-charts

helm repo update

helm install my-port-agent port-labs/port-agent \
--create-namespace --namespace port-agent \
--set env.normal.PORT_ORG_ID=YOUR_ORG_ID \
--set env.normal.KAFKA_CONSUMER_GROUP_ID=YOUR_KAFKA_CONSUMER_GROUP \
--set env.secret.KAFKA_CONSUMER_USERNAME=YOUR_KAFKA_USERNAME \
--set env.secret.KAFKA_CONSUMER_PASSWORD=YOUR_KAFKA_PASSWORD
--set env.normal.KAFKA_CONSUMER_BROKERS=PORT_KAFKA_BROKERS \
--set env.normal.STREAMER_NAME=KAFKA \
--set env.normal.KAFKA_CONSUMER_AUTHENTICATION_MECHANISM=SCRAM-SHA-512 \
--set env.normal.KAFKA_CONSUMER_AUTO_OFFSET_RESET=earliest \
--set env.normal.KAFKA_CONSUMER_SECURITY_PROTOCOL=SASL_SSL \
--set env.secret.WINDMILL_TOKEN=YOUR_WINDMILL_TOKEN \
--set-file controlThePayloadConfig=./invocations.json
```
#### Run action
Run this action with some input

```json showLineNumbers
{
"workspace": "demo",
"file_path": "f/examples/ban_user_example",
"job_data": {
"value": "batman",
"reason": "Gotham city in need of superhero",
"database": "$res:f/examples/demo_windmillshowcases",
"username": "Jack",
"slack_channel": "bans"
}
}
```

0 comments on commit 9bee619

Please sign in to comment.