bito-code-review[bot] commented on PR #15742:
URL: https://github.com/apache/grails-core/pull/15742#issuecomment-4736102053
<!-- Bito Reply -->
To handle potential `gh api` failures gracefully when `errexit` is enabled,
you should wrap the command in an `if !` block. This prevents the workflow from
aborting on a non-zero exit code and allows you to handle the error explicitly.
Here is the updated code snippet for the `gh api` call:
```bash
if ! matches="$(gh api --paginate
"repos/${GITHUB_REPOSITORY}/releases?per_page=100" \
--jq ".[] | select(.draft == false) | select((.target_commitish
| sub(\"^refs/heads/\"; \"\")) == \"${BRANCH}\") | select(.tag_name |
startswith(\"v\")) | .tag_name" 2>/dev/null)"; then
echo "::warning title=Version seed skipped::Could not list
releases for ${BRANCH}; leaving version unset (release-drafter default)."
echo "version=" >> "$GITHUB_OUTPUT"
exit 0
fi
```
**.github/workflows/release-notes.yml**
```
if ! matches="$(gh api --paginate
"repos/${GITHUB_REPOSITORY}/releases?per_page=100" \
--jq ".[] | select(.draft == false) | select((.target_commitish
| sub(\"^refs/heads/\"; \"\")) == \"${BRANCH}\") | select(.tag_name |
startswith(\"v\")) | .tag_name" 2>/dev/null)"; then
echo "::warning title=Version seed skipped::Could not list
releases for ${BRANCH}; leaving version unset (release-drafter default)."
echo "version=" >> "$GITHUB_OUTPUT"
exit 0
fi
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]