Create a Code Automation Trigger

How to create your first CodeSee Code Automation Trigger

πŸ“˜

Code Automations are a Business or Enterprise feature only.

To create a new Code Automation Trigger, navigate to the Automate home page and click "Add Trigger".

You'll be presented with a form to set up your new Trigger. After choosing a descriptive name, you'll be prompted to choose the target repository from a list. This cannot be changed after the Trigger is created.

Conditions

Next up, you will set up conditions, which are a list of criteria that determine when a Trigger should execute.

We currently support 3 types of conditions: "File location", "File contents", and "Pull Request" (more coming soon!)

Boolean logic

You can choose whether all or any of the conditions you set up apply to your Trigger:

File location

πŸ“˜

A file path is different from a file name

For example: src/app/index.ts is a file path, while index.ts is a file name.

File name condition

This condition matches the name of files in your repository.

File path condition

This condition matches the name of files in your repository.

File added in folder condition

This condition matches when files are added to a specific folder in a pull request.

For example, the filter "File added in folder" with the operator "folder path equals" with the value "src/components/icons" would match any file that was added in that icons folder (or subfolders).

An example condition that applies to files added in a folder

An example condition that applies to files added in a folder

Previewing

Use the "Preview" panel on the right to verify the conditions of your Automation.

Note: Only the various "File location" conditions affect the preview. Also, when previewing the "File added in folder" condition, the Preview panel will show existing files, but note that your Trigger will only execute when new files are added to the matching folders.

File Contents

There are three different Conditions related to matching the content of your file changes:

  • Old code
  • New code
  • New or old code

"Old code" matches against modified lines of code from before your code change: the red on the left-hand side of a split view diff.

"New code" matches against modified lines of code from after your code change: the green on the right-hand side of a split view diff.

Examples

ConditionDoes this condition match?Why?
Old codecontains"Log"YesThe modified line of code on the "Old code" side contains "Log"
New codecontains"Open"YesThe modified line of code on the "New code" side contains "Open". Even though "Open" didn't change, it still matches.
New or old codecontains"className"NoEven though "className" appears on both sides, it does not appear on the modified line of code.

Number of changed files

This condition matches when the number of files that are part of this pull request satisfy the inequality. You can choose from:

  • greater than or equal to
  • less than or equal to

PR Author

This condition matches the github login of the author of the pull request. This automation will only run if the author matches this condition.

Actions

Today, 5 kinds of actions are currently supported (with more coming soon): posting a comment, adding a checklist item, assigning a pull request, and assigning a reviewer.

Add a comment to a pull request

When this action is executed, CodeSee will post the comment on the matching pull request.

Add a checklist item to a pull request

When this action is executed, CodeSee will add a new checklist item to the PR description. You can add as many checklist items as you need by adding an action for each item.

Assign a pull request to someone

When this action is executed, CodeSee will assign the pull request to the GitHub user of your choice. If you'd like to assign multiple users, you can create multiple instances of this action on the same Trigger.

If you supply an optional message to explain why this user is being assigned, CodeSee will post a comment notifying that user and explaining why they were assigned.

Assign someone as a reviewer

When this action is executed, CodeSee will assign the person or team of your choice as a reviewer on the PR. If you'd like to add multiple reviewers, you can create multiple instances of this action on the same Trigger.

If you supply an optional message to explain why this user is being assigned as a reviewer, CodeSee will post a comment notifying that user and explaining why they were assigned as a reviewer.

Note: a pull request can never have the author of the pull request as a reviewer. If an action would cause the author to be a reviewer on their own pull request, CodeSee will skip over that action, but still perform all other actions on the trigger.

Add a label

When this action is executed, CodeSee will assign the selected GitHub label to the pull request. If you'd like to add multiple labels, you can create multiple instances of this action on the same Trigger.

Example

An example of actions defined on a Trigger

An example of actions defined on a Trigger