Workflows as code
Workflows allow you to run sequential actions and increase efficiency across development workflows. With Workflows as code, you can treat your Workflows like other production assets; this feature allows you to manage Workflows through GitOps. Each Workflow has its own YAML file.
When GitOps is enabled, changes made to Workflows will appear in GitOps logs.
Managing Workflows in both GitOps and the Cortex UI
When you enable GitOps editing for Workflows, it only affects Workflows that are backed by a YAML file. You will still be able to create and delete Workflows via the Cortex UI, and you can still edit a Workflow via the UI if it is not being managed through GitOps.
View GitOps-managed Workflows in Cortex
In the Cortex UI, you will see a Git badge appear next to any Workflows that are GitOps-managed:

You can view the Workflow in the Cortex UI, but you cannot edit in the UI. The Cortex UI will display a link to Workflow's YAML file in your repository:

Edit GitOps-managed Workflows in Cortex
You cannot edit a GitOps-managed Workflow in the Cortex UI, but you can duplicate the Workflow and make edits to the duplicate copy.
To duplicate a Workflow:
In the Workflows list, click the 3 dots icon in the row containing the Workflow.
Click Duplicate workflow.
Create a Workflow via GitOps
Step 1: Configure GitOps editing for Workflows
Navigate to Settings > GitOps then click the Workflows tab.
Toggle on the setting Enable GitOps for Workflows editing.
Optionally, under "Workflow GitOps repository allowlist," you can specify which repositories to import Workflows from.
Note that when you enable GitOps editing for Workflows, it only affects Workflows that are backed by a YAML file.
Step 2: Create a YAML file for the Workflow
Workflow YAML files must be in their own repository, separate from catalog entities, at the repository's root directly within .cortex/workflows
.
The Workflow YAML uses the same data structure as Cortex's Workflow API.
You can create a Workflow configuration from scratch, or you can start in the Cortex UI and export the Workflow to a YAML file:
At the top of the Workflow, click the 3 dots menu, then click Export Workflow YAML.
Add the YAML file to your Git repository within
.cortex/workflows
.
See an example YAML file below.
Example Workflow YAML
name: New Workflow
tag: new-workflow
description: null
isDraft: true
filter:
type: GLOBAL
runResponseTemplate: null
actions:
- name: List branches
slug: list-branches
schema:
inputs:
repo: myorg/backend-app
per_page: 30
protected: false
integrationAlias: cortex
actionIdentifier: github.listBranches
type: ADVANCED_HTTP_REQUEST
outgoingActions:
- javascript
isRootAction: true
- name: JavaScript
slug: javascript
schema:
script: |-
return fetch('https://api.ipify.org?format=json')
.then(response => {
return response.json();
})
.then(data => {
return(data);
});
type: JAVASCRIPT
outgoingActions:
- http-request
isRootAction: false
- name: HTTP request
slug: http-request
schema:
headers:
Content-Type: application/json
httpMethod: POST
payload: "{\"content\": {{{actions.javascript.outputs.return}}}}"
url: https://echo.free.beeceptor.com
type: HTTP_REQUEST
outgoingActions: []
isRootAction: false
runRestrictionPolicies: []
iconTag: null
Last updated
Was this helpful?