Skip to content

Commit

Permalink
🚀 Enhance Auto PR action with improved metadata and error handling
Browse files Browse the repository at this point in the history
This commit brings significant improvements to our Auto PR action:

🔧 Updated action metadata:
- Renamed action to "Auto PR: dev to main/master" for clarity
- Improved description to better reflect the action's functionality
- Updated author information

✨ Enhanced PR creation logic:
- Added a check to compare commits between base and head branches
- Implemented graceful handling when there are no commits to create a PR for

These changes will make the action more robust and informative, reducing potential errors and improving overall user experience. The new commit comparison feature ensures we only create PRs when there are actual changes to review, streamlining our development workflow.
  • Loading branch information
yuri-val committed Oct 21, 2024
1 parent 33a5297 commit 1c62cbf
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# action.yml

name: 'Auto PR from dev to default'
description: 'Creates or updates a PR from dev to the default branch, generates descriptions using OpenAI API, and adds reviewers.'
author: 'Your Name'
name: 'Auto PR: dev to main/master'
description: 'Creates or updates a PR from development branch to the default (main or master) branch, generates descriptions using OpenAI API, and adds reviewers.'
author: 'Yuri V'
branding:
icon: 'git-pull-request'
color: 'green'
Expand Down Expand Up @@ -148,6 +148,20 @@ runs:
const title = process.env.PR_TITLE;
const body = JSON.parse(process.env.PR_BODY);
// Check if there are any commits between base and head
const { data: comparison } = await github.rest.repos.compareCommits({
owner,
repo,
base,
head,
});
if (comparison.commits.length === 0) {
console.log('No commits between ' + base + ' and ' + head + '. Skipping PR creation.');
core.setOutput('pr_number', 'none');
return;
}
// Check if PR from dev to default branch already exists
const { data: pulls } = await github.rest.pulls.list({
owner: owner,
Expand Down

0 comments on commit 1c62cbf

Please sign in to comment.