Repository navigation
fix: parse PR number from merge commit message - #16
Merged
Merged
Conversation
The GitHub API /commits/{sha}/pulls returns empty for merge commits
because the merge commit is not part of the PR's commit list — it only
exists in main's history after the PR is closed. This caused the apply
job to fail with "Could not determine PR number".
Extract the PR number from the commit message instead, which works for
both merge strategies GitHub supports:
- Regular merge: "Merge pull request #37 from owner/branch"
- Squash merge: "Some title (#37)"
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The inline ${{ steps.apply_summarize.outputs.summary }} substitution
happens before bash evaluates the script. When the summary contains
Terragrunt output with paths like 'iac/prod/github' or tokens like
'github_repository.default[0]::', bash interprets them as commands,
causing 'command not found' errors.
Use env: + printf '%s\n' "$SUMMARY" (same pattern as the plan job's
Write plan summary to file step) to pass the value through the
environment instead of inline substitution.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
The apply job failed with:
The
/commits/{sha}/pullsGitHub API returns empty for merge commits — the merge commit only exists inmain's history after the PR closes, not in the PR's own commit list.Fix
Parse the PR number from the merge commit message, which GitHub always embeds:
Merge pull request #37 from owner/branchSome title (#37)Pattern:
grep -oP '(?<=pull request #)\d+|(?<=\(#)\d+(?=\))'🤖 Generated with Claude Code