Skip to content

Commit

Permalink
feat(github): invoke workflow (create workflow dispatch event) from e…
Browse files Browse the repository at this point in the history
…lement template (#1634)

* chore: increment Github connector version

To prepare for incoming new options

* feat: Add Actions operation group

* feat: Add workflow dispatch operation type

* feat: Display repository owner

* feat: Display Repository field

* feat: Display Workflow ID field

* feat: Display Git reference field

* feat: Display workflow inputs field

* fix: Shorten Git reference description

To make more consistent with other descriptions and reduce unnecessary
info

* fix: clarify workflow input format

Use more concise language than in the Github documentation

* fix: add file name as possible workflow ID

As documented in the Github API. In my experience so far, file name is
much easier to find than workflow ID.

* fix: remove default op type

There appears to be a bug in Desktop Modeler.

When there is only one choice in the dropdown, and a default is applied,
 other fields dependent on that choice will never bind.

 This even happens when selecting another operation group, then
 re-selecting the operation group.

* fix: add URL variable for workflows

* fix: add optional flag for workflow inputs

Without it, Modeller will fail to deploy

* fix: add POST method to create workflow

* fix: add missing forward slash to URL

* feat: add request body for workflow dispatch

* fix: make workflowInput follow JSON convention

As done in Google Drive and WhatsApp connectors.

Also, adjust inputs to work for non-null input. Will need to test with
other null input tomorrow.

* chore: move workflow objects further down

To not interfere visually with fields for other operation groups

* chore: remove "workflowInputs" id

Inconsistent with other fields in this connector.

We don't yet need to reference workflowInputs in a condition

* feat: add default {} to workflowInputs

Because a single JSON object is needed for this field.

This is similar to the approach used in WhatsApp

* chore: move inputs to correct place

Erroneously put them with body objects before

* fix: remove reference to JSON

Part of QA changes

"JSON object" was confusing, because valid FEEL objects will be
converted to JSON before being sent to GitHub

* fix: use GitHub API doc for Workflow ID

Part of QA changes

* fix: Align description with entry in camunda-docs
  • Loading branch information
ev-codes authored Jan 16, 2024
1 parent c80b73a commit 9b08e65
Showing 1 changed file with 124 additions and 4 deletions.
128 changes: 124 additions & 4 deletions connectors/github/element-templates/github-connector.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "https://unpkg.com/@camunda/zeebe-element-templates-json-schema/resources/schema.json",
"name": "GitHub Outbound Connector",
"id": "io.camunda.connectors.GitHub.v1",
"version": 4,
"version": 5,
"description": "Manage issues, branches, releases, and more",
"icon": {
"contents": "data:image/svg+xml;utf8,%3Csvg width='98' height='96' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z' fill='%2324292f'/%3E%3C/svg%3E"
Expand Down Expand Up @@ -79,6 +79,10 @@
{
"name": "Code scanning",
"value": "codeScanning"
},
{
"name": "Actions",
"value": "actions"
}
],
"binding": {
Expand Down Expand Up @@ -269,6 +273,28 @@
"name": "operationType"
}
},
{
"label": "Operation type",
"id": "operationType",
"group": "operation",
"type": "Dropdown",
"choices": [
{
"name": "Create a workflow dispatch event",
"value": "createWorkflowDispatchEvent"
}
],
"condition": {
"property": "operationGroup",
"oneOf": [
"actions"
]
},
"binding": {
"type": "zeebe:input",
"name": "operationType"
}
},
{
"type": "Hidden",
"label": "Type",
Expand Down Expand Up @@ -315,7 +341,8 @@
"mergeBranch",
"createOrganizationRepo",
"orgInvitation",
"createIssueComment"
"createIssueComment",
"createWorkflowDispatchEvent"
]
}
},
Expand Down Expand Up @@ -413,7 +440,8 @@
"updateRepo",
"listRepoContributors",
"listAlertsForRepo",
"listCommits"
"listCommits",
"createWorkflowDispatchEvent"
]
}
},
Expand Down Expand Up @@ -450,7 +478,8 @@
"updateRepo",
"listRepoContributors",
"listAlertsForRepo",
"listCommits"
"listCommits",
"createWorkflowDispatchEvent"
]
}
},
Expand Down Expand Up @@ -1153,6 +1182,67 @@
]
}
},
{
"label": "Git reference",
"description": "Branch or tag name for the workflow",
"group": "input",
"type": "String",
"feel": "optional",
"value": "",
"binding": {
"type": "zeebe:input",
"name": "gitReference"
},
"constraints": {
"notEmpty": true
},
"condition": {
"property": "operationType",
"oneOf": [
"createWorkflowDispatchEvent"
]
}
},
{
"label": "Workflow ID",
"description": "The ID of the workflow. You can also pass the workflow file name as a string.",
"group": "configuration",
"type": "String",
"feel": "optional",
"value": "",
"binding": {
"type": "zeebe:input",
"name": "workflowId"
},
"constraints": {
"notEmpty": true
},
"condition": {
"property": "operationType",
"oneOf": [
"createWorkflowDispatchEvent"
]
}
},
{
"label": "Workflow inputs",
"description": "An object containing up to 10 key-value pairs",
"group": "input",
"type": "Text",
"feel": "required",
"value": "={}",
"binding": {
"type": "zeebe:input",
"name": "workflowInputs"
},
"optional": true,
"condition": {
"property": "operationType",
"oneOf": [
"createWorkflowDispatchEvent"
]
}
},
{
"group": "configuration",
"type": "Hidden",
Expand Down Expand Up @@ -1248,6 +1338,22 @@
},
"optional": true
},
{
"group": "input",
"type": "Hidden",
"value": "={\"ref\": if gitReference = null then null else gitReference, \"inputs\":workflowInputs}",
"binding": {
"type": "zeebe:input",
"name": "body"
},
"condition": {
"property": "operationType",
"oneOf": [
"createWorkflowDispatchEvent"
]
},
"optional": true
},
{
"group": "input",
"type": "Hidden",
Expand Down Expand Up @@ -1845,6 +1951,20 @@
]
}
},
{
"type": "Hidden",
"value": "=baseUrl + \"/repos/\" + owner + \"/\" + repo + \"/actions/workflows/\" + workflowId + \"/dispatches\"",
"binding": {
"type": "zeebe:input",
"name": "url"
},
"condition": {
"property": "operationType",
"oneOf": [
"createWorkflowDispatchEvent"
]
}
},
{
"label": "Error expression",
"description": "Expression to handle errors. Details in the <a href=\"https://docs.camunda.io/docs/components/connectors/use-connectors/#bpmn-errors\" target=\"_blank\">documentation</a>",
Expand Down

0 comments on commit 9b08e65

Please sign in to comment.