Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions .github/workflows/test-pr-creation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Test PR Creation

on:
workflow_dispatch:
inputs:
pr_title:
description: "Title for the test PR"
required: false
default: "Test PR from Rovo Dev"
base_branch:
description: "Base branch for the PR (leave empty for current branch)"
required: false
default: ""

jobs:
test-pr-creation:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Run Rovo Dev with PR Creation
id: rovo-dev
uses: ./

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to understand this - for using this action from another repo, would a user just need to make sure that uses: points to this repo?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the main README file has a quick example. it's something like this

  - name: Run Rovo Dev
    uses: atlassian-labs/rovo-dev-action@v1
    with:
      prompt: "Read README.md and update the Confluence page at https://hello.atlassian.net/wiki/spaces/ROVODEV/pages/000000 to stay consistent"
      atlassian_email: ${{ secrets.ATLASSIAN_EMAIL }}
      atlassian_token: ${{ secrets.ATLASSIAN_TOKEN }}
      config_file: .rovodev/ci-config.yml

with:
prompt: |
Create a simple test file called 'test-pr-output.md' with the following content:

# Test PR Created by Rovo Dev

This file was created automatically to test PR creation functionality.

- Timestamp: $(date)
- Workflow Run: ${{ github.run_id }}
- Actor: ${{ github.actor }}
atlassian_email: ${{ secrets.ATLASSIAN_EMAIL }}
atlassian_token: ${{ secrets.ATLASSIAN_TOKEN }}
github_token: ${{ secrets.GITHUB_TOKEN }}
create_pr: "true"
pr_title: ${{ inputs.pr_title }}
pr_body: |
## Test PR

This PR was created automatically to test the PR creation functionality of the Rovo Dev GitHub Action.

**Workflow Run:** ${{ github.run_id }}
**Triggered by:** ${{ github.actor }}

---
_This PR can be safely closed without merging._
pr_base_branch: ${{ inputs.base_branch }}

- name: Output Results
run: |
echo "Exit Code: ${{ steps.rovo-dev.outputs.exit_code }}"
echo "PR Created: ${{ steps.rovo-dev.outputs.pr_created }}"
echo "PR URL: ${{ steps.rovo-dev.outputs.pr_url }}"
echo "Branch Name: ${{ steps.rovo-dev.outputs.branch_name }}"
78 changes: 78 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,45 @@ inputs:
description: "Path to a custom Rovo Dev configuration file (YAML). If provided, this will be passed to the CLI via --config-file."
required: false
default: ""
# GitHub PR creation inputs
github_token:
description: "GitHub token for PR creation and repository operations. Required if create_pr is true."
required: false
default: ""
create_pr:
description: "Whether to automatically create a PR with changes made by Rovo Dev"
required: false
default: "false"
pr_title:
description: "Title for the PR (used if create_pr is true)"
required: false
default: "Changes by Rovo Dev"
pr_body:
description: "Body/description for the PR (used if create_pr is true)"
required: false
default: "Automated changes by Rovo Dev"
pr_base_branch:
description: "Base branch for PR creation. Defaults to the current branch if not specified."
required: false
default: ""
branch_prefix:
description: "Prefix for auto-created branches"
required: false
default: "rovodev/"

outputs:
exit_code:
description: "Exit code from Rovo Dev CLI execution"
value: ${{ steps.run-rovo-dev.outputs.exit_code }}
pr_created:
description: "Whether a PR was created (true/false)"
value: ${{ steps.create-pr.outputs.pr_created }}
pr_url:
description: "URL of the created PR (if pr_created is true)"
value: ${{ steps.create-pr.outputs.pr_url }}
branch_name:
description: "Name of the branch created for the PR"
value: ${{ steps.branch-setup.outputs.branch_name }}

runs:
using: "composite"
Expand Down Expand Up @@ -93,6 +127,31 @@ runs:
echo "$ATLASSIAN_TOKEN" | acli rovodev auth login --email "$ATLASSIAN_EMAIL" --token
echo "Authentication successful"

- name: Setup Git Identity
if: ${{ inputs.create_pr == 'true' }}
shell: bash
run: |
git config --global user.name "Rovo Dev"
git config --global user.email "rovodev[bot]@users.noreply.github.com"

- name: Create Feature Branch
if: ${{ inputs.create_pr == 'true' }}
id: branch-setup
shell: bash
run: |
# Determine base branch: use input if provided, otherwise detect current branch
BASE_BRANCH="${{ inputs.pr_base_branch }}"
if [ -z "$BASE_BRANCH" ]; then
BASE_BRANCH=$(git rev-parse --abbrev-ref HEAD)
echo "No base branch specified, using current branch: $BASE_BRANCH"
fi

"${{ github.action_path }}/scripts/branch-setup.sh" \
"run" \
"${{ github.run_number }}" \
"$BASE_BRANCH" \
"${{ inputs.branch_prefix }}"

- name: Run Rovo Dev CLI
id: run-rovo-dev
shell: bash
Expand Down Expand Up @@ -127,3 +186,22 @@ runs:
fi

exit $EXIT_CODE

- name: Create Pull Request
if: ${{ inputs.create_pr == 'true' && steps.run-rovo-dev.outputs.exit_code == '0' }}
id: create-pr
shell: bash
env:
GH_TOKEN: ${{ inputs.github_token }}
run: |
# Use the same base branch that was used for branch setup
BASE_BRANCH="${{ inputs.pr_base_branch }}"
if [ -z "$BASE_BRANCH" ]; then
BASE_BRANCH="${{ steps.branch-setup.outputs.base_branch }}"
fi

"${{ github.action_path }}/scripts/create-pr.sh" \
"${{ steps.branch-setup.outputs.branch_name }}" \
"$BASE_BRANCH" \
"${{ inputs.pr_title }}" \
"${{ inputs.pr_body }}"
31 changes: 31 additions & 0 deletions scripts/branch-setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash
# Setup a new branch for Rovo Dev changes
# This script creates a unique branch for PR creation

set -e

ENTITY_TYPE="${1:-automation}"
ENTITY_NUMBER="${2:-0}"
BASE_BRANCH="${3:-main}"
BRANCH_PREFIX="${4:-rovodev/}"

# Create timestamp for unique branch name
TIMESTAMP=$(date +"%Y%m%d-%H%M%S")

# Create branch name
BRANCH_NAME="${BRANCH_PREFIX}${ENTITY_TYPE}-${ENTITY_NUMBER}-${TIMESTAMP}"

echo "Setting up branch: $BRANCH_NAME"

# Configure git for CI environment
git config --global --add safe.directory "$PWD"

# Fetch the base branch
git fetch origin "$BASE_BRANCH" --depth=1

# Create and checkout new branch from base
git checkout -b "$BRANCH_NAME" "origin/$BASE_BRANCH"

echo "Successfully created branch: $BRANCH_NAME"
echo "branch_name=$BRANCH_NAME" >> "$GITHUB_OUTPUT"
echo "base_branch=$BASE_BRANCH" >> "$GITHUB_OUTPUT"
49 changes: 49 additions & 0 deletions scripts/create-pr.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/bash
# Create a Pull Request with Rovo Dev changes
# This script commits any changes and creates a PR

set -e

BRANCH_NAME="$1"
BASE_BRANCH="$2"
PR_TITLE="$3"
PR_BODY="$4"

if [ -z "$BRANCH_NAME" ] || [ -z "$BASE_BRANCH" ]; then
echo "::error::Missing required arguments: branch_name and base_branch"
exit 1
fi

# Check if there are any changes to commit
if git diff --quiet && git diff --staged --quiet; then
echo "No changes detected. Skipping PR creation."
echo "pr_created=false" >> "$GITHUB_OUTPUT"
exit 0
fi

# Stage all changes
git add -A

# Check again after staging (for new files)
if git diff --staged --quiet; then
echo "No changes to commit after staging. Skipping PR creation."
echo "pr_created=false" >> "$GITHUB_OUTPUT"
exit 0
fi

# Commit changes
git commit -m "${PR_TITLE:-Changes by Rovo Dev}"

# Push the branch
git push origin "$BRANCH_NAME"

# Create the PR using GitHub CLI
PR_URL=$(gh pr create \
--title "${PR_TITLE:-Changes by Rovo Dev}" \
--body "${PR_BODY:-Automated changes by Rovo Dev}" \
--base "$BASE_BRANCH" \
--head "$BRANCH_NAME")

echo "Successfully created PR: $PR_URL"
echo "pr_created=true" >> "$GITHUB_OUTPUT"
echo "pr_url=$PR_URL" >> "$GITHUB_OUTPUT"