Skip to main content

Simple Pull Request Workflow

This example demonstrates a basic Bosun workflow that uses a coding agent to create a new file based on a user-provided input, and then automatically opens a draft pull request for these changes. This showcases how Bosun can automate simple content generation and integrate with your version control system.

Workflow Definition (bosun.yaml)

name: create-file-and-pr-from-input
description: Creates a file with user-defined content and opens a draft pull request.

inputs:
fileName:
type: String
required: true
description: The name of the file to create (e.g., 'my-new-feature.md').
fileContent:
type: String
required: true
description: The content to write into the new file.

steps:
- name: Create a new file with provided content
agent:
extends: Coding
instructions: "Create a new file named '{{ inputs.fileName }}' in the root directory with the following content: '{{ inputs.fileContent }}'"
role: "You are a helpful assistant that creates files based on instructions."
constraints:
- "Ensure the file is created exactly as specified."
- "Do not make any other changes."

- name: Create a draft pull request
agent:
extends: pull_request
instructions: "Create a draft pull request for the changes made by the previous step."
tools:
- name: update_pull_request
extends: create_or_update_pull_request
with:
draft: true

How it Works

  1. Inputs: The workflow defines several inputs (fileName, fileContent, prTitle, prBody) that allow you to customize its behavior when you trigger it.
  2. Create File Step: An agent with the Coding extension is instructed to create a new file. It uses the {{ inputs.fileName }} and {{ inputs.fileContent }} templates to dynamically set the file's name and content based on your input.
  3. Create Pull Request Step: A dedicated pull_request agent is then used to create a draft pull request. The draft: true setting ensures the PR is created as a draft, ready for further review or updates.