2025-03-07 20:13:20 +01:00
---
title: CI/CD Environments
2025-11-24 11:05:41 -08:00
description: Set up goose in your CI/CD pipeline to automate tasks
2025-03-07 20:13:20 +01:00
---
import Tabs from '@theme/Tabs ';
import TabItem from '@theme/TabItem ';
2025-11-24 11:05:41 -08:00
goose isn’ t just useful on your local machine, it can also streamline tasks in CI/CD environments. By integrating goose into your pipeline, you can automate tasks such as:
2025-03-07 20:13:20 +01:00
- Code reviews
- Documentation checks
- Build and deployment workflows
- Infrastructure and environment management
- Rollbacks and recovery processes
- Intelligent test execution
2025-11-24 11:05:41 -08:00
This guide walks you through setting up goose in your CI/CD pipeline, with a focus on using GitHub Actions for code reviews.
2025-03-07 20:13:20 +01:00
2025-11-24 11:05:41 -08:00
## Using goose with GitHub Actions
You can run goose directly within GitHub Actions. Follow these steps to set up your workflow.
2025-03-07 20:13:20 +01:00
:::info TLDR
<details>
<summary>Copy the GitHub Workflow</summary>
```yaml title="goose.yml"
2025-08-23 01:44:55 +05:30
2025-11-24 11:05:41 -08:00
name: goose
2025-08-23 01:44:55 +05:30
on:
pull_request:
types: [opened, synchronize, reopened, labeled]
permissions:
contents: write
pull-requests: write
issues: write
env:
PROVIDER_API_KEY: ${{ secrets.REPLACE_WITH_PROVIDER_API_KEY }}
PR_NUMBER: ${{ github.event.pull_request.number }}
GH_TOKEN: ${{ github.token }}
jobs:
goose-comment:
2025-11-24 11:05:41 -08:00
name: goose Comment
2025-08-23 01:44:55 +05:30
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Gather PR information
run: |
{
echo "# Files Changed"
gh pr view $PR_NUMBER --json files \
-q '.files[] | "* " + .path + " (" + (.additions|tostring) + " additions, " + (.deletions|tostring) + " deletions)"'
echo ""
echo "# Changes Summary"
gh pr diff $PR_NUMBER
} > changes.txt
2025-11-24 11:05:41 -08:00
- name: Install goose CLI
2025-08-23 01:44:55 +05:30
run: |
mkdir -p /home/runner/.local/bin
2026-04-07 01:34:48 -04:00
curl -fsSL https://github.com/aaif-goose/goose/releases/download/stable/download_cli.sh \
2026-02-11 17:24:37 -08:00
| GOOSE_VERSION=REPLACE_WITH_VERSION CONFIGURE=false GOOSE_BIN_DIR=/home/runner/.local/bin bash
2025-08-23 01:44:55 +05:30
echo "/home/runner/.local/bin" >> $GITHUB_PATH
2025-11-24 11:05:41 -08:00
- name: Configure goose
2025-08-23 01:44:55 +05:30
run: |
mkdir -p ~/.config/goose
cat <<EOF > ~/.config/goose/config.yaml
GOOSE_PROVIDER: REPLACE_WITH_PROVIDER
GOOSE_MODEL: REPLACE_WITH_MODEL
keyring: false
EOF
2025-11-24 11:05:41 -08:00
- name: Create instructions for goose
2025-08-23 01:44:55 +05:30
run: |
cat <<EOF > instructions.txt
Create a summary of the changes provided. Don't provide any session or logging details.
The summary for each file should be brief and structured as:
<filename/path (wrapped in backticks)>
- dot points of changes
You don't need any extensions, don't mention extensions at all.
The changes to summarise are:
$(cat changes.txt)
EOF
- name: Test
run: cat instructions.txt
2025-11-24 11:05:41 -08:00
- name: Run goose and filter output
2025-08-23 01:44:55 +05:30
run: |
goose run --instructions instructions.txt | \
# Remove ANSI color codes
sed -E 's/\x1B\[[0-9;]*[mK]//g' | \
# Remove session/logging lines
grep -v "logging to /home/runner/.config/goose/sessions/" | \
grep -v "^starting session" | \
grep -v "^Closing session" | \
# Trim trailing whitespace
sed 's/[[:space:]]*$//' \
> pr_comment.txt
- name: Post comment to PR
run: |
cat -A pr_comment.txt
gh pr comment $PR_NUMBER --body-file pr_comment.txt
2025-03-07 20:13:20 +01:00
` ``
</details>
:::
### 1. Create the Workflow File
Create a new file in your repository at ` .github/workflows/goose.yml`. This will contain your GitHub Actions workflow.
### 2. Define the Workflow Triggers and Permissions
Configure the action such that it:
- Triggers the workflow when a pull request is opened, updated, reopened, or labeled
2025-11-24 11:05:41 -08:00
- Grants the necessary permissions for goose to interact with the repository
2025-03-07 20:13:20 +01:00
- Configures environment variables for your chosen LLM provider
` ``yaml
2025-11-24 11:05:41 -08:00
name: goose
2025-03-07 20:13:20 +01:00
on:
pull_request:
types: [opened, synchronize, reopened, labeled]
permissions:
contents: write
pull-requests: write
issues: write
env:
PROVIDER_API_KEY: ${{ secrets.REPLACE_WITH_PROVIDER_API_KEY }}
PR_NUMBER: ${{ github.event.pull_request.number }}
` ``
2025-11-24 11:05:41 -08:00
### 3. Install and Configure goose
2025-03-07 20:13:20 +01:00
2025-11-24 11:05:41 -08:00
To install and set up goose in your workflow, add the following steps:
2025-03-07 20:13:20 +01:00
` ``yaml
steps:
2025-11-24 11:05:41 -08:00
- name: Install goose CLI
2025-03-07 20:13:20 +01:00
run: |
mkdir -p /home/runner/.local/bin
2026-04-07 01:34:48 -04:00
curl -fsSL https://github.com/aaif-goose/goose/releases/download/stable/download_cli.sh \
2026-02-11 17:24:37 -08:00
| GOOSE_VERSION=REPLACE_WITH_VERSION CONFIGURE=false GOOSE_BIN_DIR=/home/runner/.local/bin bash
2025-03-07 20:13:20 +01:00
echo "/home/runner/.local/bin" >> $GITHUB_PATH
2025-11-24 11:05:41 -08:00
- name: Configure goose
2025-03-07 20:13:20 +01:00
run: |
mkdir -p ~/.config/goose
cat <<EOF > ~/.config/goose/config.yaml
GOOSE_PROVIDER: REPLACE_WITH_PROVIDER
GOOSE_MODEL: REPLACE_WITH_MODEL
keyring: false
EOF
` ``
2026-02-11 17:24:37 -08:00
#### Pinning goose versions in CI/CD
In CI/CD, we recommend pinning a specific goose version with ` GOOSE_VERSION` for reproducible runs. This also avoids 404 errors when downloading the goose CLI binary assets if the ` stable` release tag doesn’ t include them.
Relevant installer options for CI:
- ` GOOSE_VERSION`: the version to pin the install to (both ` 1.21.1` and ` v1.21.1` formats are supported)
- ` GOOSE_BIN_DIR`: install directory (make sure this directory is on ` PATH`)
- ` CONFIGURE=false`: skip interactive ` goose configure` flow
2025-03-07 20:13:20 +01:00
:::info Replacements
2026-02-11 17:24:37 -08:00
Replace ` REPLACE_WITH_VERSION`, ` REPLACE_WITH_PROVIDER`, and ` REPLACE_WITH_MODEL` with the goose version you want to pin and your LLM provider/model names. Add any other necessary configuration required.
2025-03-07 20:13:20 +01:00
:::
### 4. Gather PR Changes and Prepare Instructions
2025-11-24 11:05:41 -08:00
This step extracts pull request details and formats them into structured instructions for goose.
2025-03-07 20:13:20 +01:00
` ``yaml
2025-11-24 11:05:41 -08:00
- name: Create instructions for goose
2025-03-07 20:13:20 +01:00
run: |
cat <<EOF > instructions.txt
Create a summary of the changes provided. Don't provide any session or logging details.
The summary for each file should be brief and structured as:
<filename/path (wrapped in backticks)>
- dot points of changes
You don't need any extensions, don't mention extensions at all.
The changes to summarise are:
$(cat changes.txt)
EOF
` ``
2025-11-24 11:05:41 -08:00
### 5. Run goose and Clean Output
2025-03-07 20:13:20 +01:00
2025-11-24 11:05:41 -08:00
Now, run goose with the formatted instructions and clean the output by removing ANSI color codes and unnecessary log messages.
2025-03-07 20:13:20 +01:00
` ``yaml
2025-11-24 11:05:41 -08:00
- name: Run goose and filter output
2025-03-07 20:13:20 +01:00
run: |
goose run --instructions instructions.txt | \
# Remove ANSI color codes
sed -E 's/\x1B\[[0-9;]*[mK]//g' | \
# Remove session/logging lines
grep -v "logging to /home/runner/.config/goose/sessions/" | \
grep -v "^starting session" | \
grep -v "^Closing session" | \
# Trim trailing whitespace
sed 's/[[:space:]]*$//' \
> pr_comment.txt
` ``
### 6. Post Comment to PR
2025-11-24 11:05:41 -08:00
Finally, post the goose output as a comment on the pull request:
2025-03-07 20:13:20 +01:00
` ``yaml
- name: Post comment to PR
run: |
cat -A pr_comment.txt
gh pr comment $PR_NUMBER --body-file pr_comment.txt
` ``
2025-11-24 11:05:41 -08:00
With this workflow, goose will run on pull requests, analyze the changes, and post a summary as a comment on the PR.
2025-03-07 20:13:20 +01:00
This is just one example of what's possible. Feel free to modify your GitHub Action to meet your needs.
---
2026-01-30 11:44:18 -08:00
## Running Multiple goose Instances in Parallel
goose supports running multiple concurrent sessions with isolated state, making it safe to run parallel jobs in your CI/CD pipeline. Each goose instance maintains its own conversation history, agent context, and extension configurations without interference.
This enables use cases like matrix builds across different environments or processing multiple components simultaneously.
---
2025-03-07 20:13:20 +01:00
## Security Considerations
2026-01-23 17:44:35 -08:00
When running goose in a CI/CD environment, keep these security practices in mind:
2025-03-07 20:13:20 +01:00
1. **Secret Management **
- Store your sensitive credentials (like API keys) as GitHub Secrets.
- Never expose these credentials in logs or PR comments.
2. **Principle of Least Privilege **
- Grant only the necessary permissions in your workflow and regularly audit them.
3. **Input Validation **
2025-11-24 11:05:41 -08:00
- Ensure any inputs passed to goose are sanitized and validated to prevent unexpected behavior.