# Run and manage workflows

You can run and manage workflows from the environments view. Execute workflows manually, automatically via Git triggers, or on a cron schedule. Monitor workflow runs and roll back to previous deployments.

Select the environment that contains the workflow you want to manage from the environments view. You can run a workflow, or click the options button to view runs or edit the workflow.

## Run a workflow manually

You can run a workflow by clicking run in the workflow header.

1. Navigate to **Environments** in your project

2. Click on a workflow to open it

3. Click **Run** in the header

4. Configure the run (optional):
  
  
  
  - **Name**: Enter a descriptive name for this run
  
  - **Description**: Add details about what this release includes
  
  - **Git triggers**: Select branch and commit for each configured Git trigger
  
  - **Arguments**: Override default argument values

5. Click **Create**

![Running a workflow in the Northflank application](https://assets.northflank.com/documentation/v1/application/getting-started/set-up-environments/run-workflow.png)

If you do not enter a name for the run it will display a generated UUID, but you can edit the display name afterwards.

If the workflow contains build or deployment nodes you will be able to override the configured build or image to deploy, if required.

The workflow executes and you can monitor its progress in the run view.

## Use Git triggers to run workflows

You can [add Git triggers in the workflow settings](/v1/application/release/configure-workflows#add-triggers).

A trigger will run the workflow whenever a change to the specified repository is committed.

You can include:

- **Branch and pull request rules** to only trigger on commits to specific branches or pull requests

- **Path rules** to only trigger on changes to specific directories or files in a repository, or to ignore changes to specific directories or files

- **Commit message ignore flags** to skip runs for commits with messages that contain certain strings

You can use references to obtain the values of Git triggers in your workflow nodes.

## Use cron schedules to run workflows

Workflows can run automatically on a repeating schedule. This is useful for regular deployments, periodic maintenance tasks, or refreshing test environments.

To add a cron trigger:

1. Open your workflow

2. Click the plus sign or **Add trigger**

3. Select **Cron schedule** from the **Kind** dropdown

4. Enter a cron expression in the **Schedule** field (times are UTC, minimum interval is 10 minutes)

Each workflow can have one cron trigger.

## Run a workflow using a webhook

You can trigger a workflow run by making a GET or POST request to a workflow's webhook endpoint.

You can include query parameters at the end of the webhook URL to pass values directly to your workflow as arguments.

### Git trigger parameters

You can override the values for Git triggers configured in your workflow using a webhook. For example, you may have configured a workflow to build from multiple repositories, or to build from specific directories in a single repository, and need to override the default branch and commit for each trigger.

To set the values for specific triggers, use the name of the Git trigger followed by the field name in dot notation:

| Parameter | Value |
| --- | --- |
| `<git-trigger>.branch` | The branch name |
| `<git-trigger>.sha` | The commit SHA |
| `<git-trigger>.pullRequestId` | The ID of the pull request |
| `<git-trigger>.repoUrl` | The repository URL |

For example, the following endpoint would run a workflow and set the branch for the Git trigger `frontend` to `feature` and the branch for the trigger `backend` to `develop`:

`https://webhooks.northflank.com/workflows/<TOKEN>?frontend.branch=feature&backend.branch=develop`

### Workflow name and description

You can pass in optional values to set the `name` and `description` for a workflow run, otherwise the workflow will be given a random identifier as the name and no description.

### Other values

You can also add whatever other URL query parameters you require. For example, triggering a workflow with the following parameters: `https://webhooks.northflank.com/workflows/<TOKEN>?foo=bar` would make `${args.foo}` available in the workflow, resolving to the value `bar`.

You can use this to pass in secrets or configuration details for your workflow, or set the branch and commit in build nodes that don't have any Git triggers configured.

## View runs

The state of the current or most recent workflow run is indicated in the workflow header. This can be clicked to view the currently running workflow, or the list of previous runs.

### Workflow run statuses

Pending: the workflow is scheduled to run
Running: the workflow is currently running
Success: all of the nodes within the workflow completed successfully
Failed: some or all of the nodes within the workflow failed to complete successfully

### View workflow runs

Click on a workflow and click **view runs**.

This displays a list of previous and current workflow runs and their status. You can also see when the workflow was run, and when it was completed.

### Node statuses

Pending: the node or workflow will run when previous steps are executed successfully
Running: the node or workflow is currently being executed
Waiting: the node is waiting for an action to be completed, will eventually timeout unless it receives a successful response
Retrying: the node has failed on previous runs, but is being executed again (up to 3 attempts)
Success: the node or workflow has completed successfully
Failed: the node or workflow has failed to execute, or exceeded 3 retries

## Re-run a workflow

You can re-run a previous workflow run to execute the same workflow with the same structure and arguments.

1. Navigate to **Environments** in your project

2. Click on a workflow

3. Click **View runs** in the sidebar

4. Click on the **Re-trigger** icon on the run you want to rerun

The workflow will execute again with the same configuration and arguments as the selected run. This allows you to re-execute a previous workflow without manually configuring it again.

## Next steps

- [Set up preview blueprints: Create preview blueprints to automatically create preview environments for your branches and pull requests.](/v1/application/release/set-up-preview-blueprints)
- [Manage preview blueprints: Manage active previews, manually create test environments, and configure automatic cleanup.](/v1/application/release/manage-preview-blueprints)
- [Run migrations: Run database migrations and update your deployments simultaneously when you update your schema.](/v1/application/release/run-migrations)
