Skip to content

Commit 9a693f2

Browse files
committed
try writing to GH_OUT file better
1 parent 23f5df6 commit 9a693f2

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

cpp-linter-lib/src/rest_api/github_api.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -128,15 +128,16 @@ impl RestApiClient for GithubApiClient {
128128
.append(true)
129129
.open(gh_out)
130130
.expect("GITHUB_OUTPUT file could not be opened");
131-
if let Err(e) = writeln!(
132-
gh_out_file,
133-
"checks-failed={}\nformat-checks-failed={}\ntidy-checks-failed={}",
134-
checks_failed,
135-
format_checks_failed.unwrap_or(0),
136-
tidy_checks_failed.unwrap_or(0),
137-
) {
138-
log::error!("Could not write to GITHUB_OUTPUT file: {}", e);
131+
for (prompt, value) in [
132+
("checks-failed", Some(checks_failed)),
133+
("format-checks-failed", format_checks_failed),
134+
("tidy-checks-failed", tidy_checks_failed),
135+
] {
136+
if let Err(e) = writeln!(gh_out_file, "{prompt}={}", value.unwrap_or(0),) {
137+
log::error!("Could not write to GITHUB_OUTPUT file: {}", e);
138+
}
139139
}
140+
gh_out_file.flush().expect("Failed to flush buffer to GITHUB_OUTPUT file");
140141
}
141142
log::info!(
142143
"{} clang-format-checks-failed",

0 commit comments

Comments
 (0)