-
Notifications
You must be signed in to change notification settings - Fork 1
feat(action): add GitHub PR creation capability #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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: ./ | ||
| 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 }}" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?There was a problem hiding this comment.
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