From 1c62cbfe881bd5056a15b608d8f3f728a9263432 Mon Sep 17 00:00:00 2001 From: Yuri V Date: Tue, 22 Oct 2024 00:57:35 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=80=20Enhance=20Auto=20PR=20action=20w?= =?UTF-8?q?ith=20improved=20metadata=20and=20error=20handling?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- action.yml | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/action.yml b/action.yml index c8c6b10..b416153 100644 --- a/action.yml +++ b/action.yml @@ -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' @@ -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,