mirror of
https://github.com/softprops/action-gh-release.git
synced 2025-10-10 18:41:39 +00:00
fix: gracefully fallback to body when body_path cannot be read (#671)
* Initial plan * fix: gracefully fallback to body when body_path cannot be read Co-authored-by: chenrui333 <1580956+chenrui333@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: chenrui333 <1580956+chenrui333@users.noreply.github.com>
This commit is contained in:
15
src/util.ts
15
src/util.ts
@@ -35,10 +35,17 @@ export const uploadUrl = (url: string): string => {
|
||||
};
|
||||
|
||||
export const releaseBody = (config: Config): string | undefined => {
|
||||
return (
|
||||
(config.input_body_path && readFileSync(config.input_body_path).toString('utf8')) ||
|
||||
config.input_body
|
||||
);
|
||||
if (config.input_body_path) {
|
||||
try {
|
||||
const contents = readFileSync(config.input_body_path, 'utf8');
|
||||
return contents;
|
||||
} catch (err: any) {
|
||||
console.warn(
|
||||
`⚠️ Failed to read body_path "${config.input_body_path}" (${err?.code ?? 'ERR'}). Falling back to 'body' input.`,
|
||||
);
|
||||
}
|
||||
}
|
||||
return config.input_body;
|
||||
};
|
||||
|
||||
type Env = { [key: string]: string | undefined };
|
||||
|
Reference in New Issue
Block a user