Pull Request Commands

Run workflows from GitHub Pull Requests

With our GitHub app installed and your repository connected to your CTO.ai Team, you can trigger workflows from the comments of Pull Requests using a ChatOps-style /ops run command. To give your team this ability:

  • Install the CTO.ai GitHub App in your GitHub organization and connect your repository to the CTO.ai platform.

  • Ensure each member of your team has associated their CTO.ai profile with their GitHub profile.

  • Ensure each user who should be able to trigger workflows has been invited to your CTO.ai team.

Unless all three of the above conditions are met, it will not be possible to trigger workflows from Pull Request comments.

Using ChatOps in Pull Requests

Before you can run a workflow using Pull Request /ops run commands, you must build and publish that workflow to the CTO.ai platform to make it accessible to members of your CTO.ai Team. To run one of your published CTO.ai workflows from a GitHub Pull Request, post /ops run [WORKFLOW] as a comment, replacing [WORKFLOW] with the name of the workflow to run:

Example `/ops run` comment which triggers a `github-pr-workflow-interaction` workflow published on the CTO.ai platform.
Example `/ops run` comment which triggers a `github-pr-workflow-interaction` workflow published on the CTO.ai platform.

Please take note of these limitations when using /ops run commands in Pull Requests on GitHub:

  • ChatOps interactions on GitHub Pull Request comments are limited to triggering your workflows with the /ops run command. You should use the CTO.ai CLI or our Slack integration if you need to trigger interactive ChatOps workflows, manage your team, or modify your Configs and Secrets values.
  • To help prevent unauthorized access to your infrastructure, a pull request comment may only trigger a workflow on the CTO.ai platform if the commenter is a member of your CTO.ai team associated with that GitHub repository. This means that each member of your team must associate their CTO.ai account with their GitHub account before attempting to execute an /ops run command in a pull request comment.

Pull Request DORA Metrics

To retrieve a snapshot of your team’s DORA Metrics for a given Pull Request, you can use the /ops measure command to trigger the CTO.ai bot to post a comment with the snapshot in the Pull Request conversation. For more information on using /ops measure, see the Snapshot DORA Metrics for a Pull Request page.

Usage Examples

Consider a simple ops.yml file example defining a CTO.ai Pipeline:

As you can see, the github-pr-workflow-interaction Pipeline specifies an events key, which defines a Pipeline that should run when a Pull Request is opened in the GitHub repo at GITHUB_ORG/GITHUB_REPO. Once we build this workflow and publish it to our CTO.ai team, one job containing one step (echo "GitHub Interactions") will be executed each time a pull request is opened in our repo.

If we need to run this workflow a second time for our Pull Request (or run it on a Pull Request that was opened before the workflow was published!), we can use the /ops run command to execute our workflow directly from the comments of our Pull Request.

Workflows triggered by /ops run commands in Pull Request comments will display their progress and output in the check runs section of the page. For example, entering a command such as /ops run faux-linter would run the faux-linter workflow published to your CTO.ai team, and that produces output resembling the screenshot below:

Clicking on the Details button in the check run section at the bottom of the Pull Request will show you the output from the workflow you ran, as it progresses.

The output from runs of two different workflows, with an example check run overview from GitHub on the left side, and the output displayed on the CTO.ai Dashboard on the right side.
The output from runs of two different workflows, with an example check run overview from GitHub on the left side, and the output displayed on the CTO.ai Dashboard on the right side.

Clicking on the Run ID from the check run overview page for a workflow you’ve run will take you to the CTO.ai Dashboard, where you can view more information about your run.

Troubleshooting

If you are having issues triggering CTO.ai workflows from GitHub Pull Request comments or are receiving error messages from our GitHub bot, review the table below for a list of common problems and our recommended troubleshooting actions for each.

Problem or ErrorTroubleshooting Action
Nothing appears on a Pull Request after posting an /ops run command as a commentCheck that the CTO.ai GitHub App is installed and enabled in the GitHub organization that owns the repository containing the Pull Request.
CTO.ai bot shows the error message Unrecognized [user]

Ensure each user interacting with the bot provided by our GitHub App meets all of the following conditions:

  • User has a CTO.ai account
  • User’s CTO.ai profile is linked with their GitHub profile
CTO.ai bot show the error message [user] doesn't belong to the CTO.ai team that owns this repositoryThis indicates that the GitHub user interacting with our bot has linked their GitHub profile to their CTO.ai profile, but the user’s CTO.ai profile has not been invited to the CTO.ai team associated with the repository.