Claude's changes for CodeRabbit suggestion
This commit is contained in:
55
.github/workflows/versioning.yml
vendored
55
.github/workflows/versioning.yml
vendored
@@ -48,36 +48,36 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
script: |
|
script: |
|
||||||
try {
|
try {
|
||||||
// Get the commit that triggered this workflow
|
// Use GitHub's reliable API to find PRs associated with this commit
|
||||||
const commit = await github.rest.repos.getCommit({
|
const { data: associatedPRs } = await github.rest.repos.listPullRequestsAssociatedWithCommit({
|
||||||
owner: context.repo.owner,
|
owner: context.repo.owner,
|
||||||
repo: context.repo.repo,
|
repo: context.repo.repo,
|
||||||
ref: context.sha
|
commit_sha: context.sha
|
||||||
});
|
});
|
||||||
|
|
||||||
// Look for PR number in commit message (GitHub merge commits include this)
|
if (associatedPRs.length > 0) {
|
||||||
const commitMessage = commit.data.commit.message;
|
// Get the most recent merged PR
|
||||||
const prMatch = commitMessage.match(/Merge pull request #(\d+)/);
|
const pr = associatedPRs.find(pr => pr.state === 'closed' && pr.merged_at) || associatedPRs[0];
|
||||||
|
|
||||||
if (prMatch) {
|
return {
|
||||||
const prNumber = parseInt(prMatch[1]);
|
title: pr.title,
|
||||||
const pr = await github.rest.pulls.get({
|
body: pr.body || 'No description provided',
|
||||||
|
number: pr.number,
|
||||||
|
found: true
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
// Fallback for direct pushes or when no PR is found
|
||||||
|
const commit = await github.rest.repos.getCommit({
|
||||||
owner: context.repo.owner,
|
owner: context.repo.owner,
|
||||||
repo: context.repo.repo,
|
repo: context.repo.repo,
|
||||||
pull_number: prNumber
|
ref: context.sha
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
|
||||||
title: pr.data.title,
|
|
||||||
body: pr.data.body || 'No description provided',
|
|
||||||
number: prNumber
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
// Fallback for direct pushes
|
|
||||||
return {
|
return {
|
||||||
title: 'Direct push to main',
|
title: 'Direct push to main',
|
||||||
body: commitMessage,
|
body: commit.data.commit.message,
|
||||||
number: null
|
number: null,
|
||||||
|
found: false
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -85,7 +85,8 @@ jobs:
|
|||||||
return {
|
return {
|
||||||
title: 'Version update',
|
title: 'Version update',
|
||||||
body: 'Automated version bump',
|
body: 'Automated version bump',
|
||||||
number: null
|
number: null,
|
||||||
|
found: false
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,19 +100,15 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
NEW_VERSION=$(cat ./versioning/VERSION)
|
NEW_VERSION=$(cat ./versioning/VERSION)
|
||||||
|
|
||||||
if [ "${{ github.event_name }}" == "push" ]; then
|
if [ "${{ github.event_name }}" == "push" ] && [ "${{ steps.pr_info.outcome }}" == "success" ]; then
|
||||||
# Use PR information from previous step
|
# Use PR information directly in heredoc to avoid quoting issues
|
||||||
PR_TITLE='${{ fromJson(steps.pr_info.outputs.result).title }}'
|
|
||||||
PR_BODY='${{ fromJson(steps.pr_info.outputs.result).body }}'
|
|
||||||
|
|
||||||
# Create formatted tag message
|
|
||||||
cat > tag_message.txt << EOF
|
cat > tag_message.txt << EOF
|
||||||
# v${NEW_VERSION} - ${PR_TITLE}
|
# v${NEW_VERSION} - ${{ fromJson(steps.pr_info.outputs.result).title }}
|
||||||
|
|
||||||
${PR_BODY}
|
${{ fromJson(steps.pr_info.outputs.result).body }}
|
||||||
EOF
|
EOF
|
||||||
else
|
else
|
||||||
# Manual dispatch - simpler message
|
# Manual dispatch or PR info unavailable - simpler message
|
||||||
cat > tag_message.txt << EOF
|
cat > tag_message.txt << EOF
|
||||||
# v${NEW_VERSION} - Manual tag update
|
# v${NEW_VERSION} - Manual tag update
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user