Skip to content

Commit 327b8a7

Browse files
committed
check-run: persist parameters in an Action state
... and reuse it when called a second time. That way, one can update, say, only the text, without having to re-specify all the details _again_. For technical details, the token and the config _do_ need to be re-specified again (the token because of security concerns, the config so that the appropriate token can be used just in case that pr-repo and upstream-repo can be handled by the same workflow). Note: Instead of using `core.saveState()`, the state is explicitly persisted via the environment variable `STATE_check-run` (yes, it _is_ a funny name). The reasons for that are: 1. Subsequent invocations of the Action would _not_ get the state, only the `post` Action would. 2. The `post` Action would only receive the state saved by the _first_ Action invocation, subsequent `saveState()` calls would be ignored! Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 8b37c6d commit 327b8a7

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/ci-helper.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ export class CIHelper {
300300
details_url?: string;
301301
conclusion?: ConclusionType;
302302
};
303-
const params = {} as CheckRunParameters;
303+
const params = JSON.parse(core.getState("check-run") || "{}") as CheckRunParameters;
304304

305305
const validateCheckRunParameters = () => {
306306
const result = typia.createValidate<CheckRunParameters>()(params);
@@ -312,6 +312,7 @@ export class CIHelper {
312312
);
313313
}
314314
};
315+
if (Object.keys(params).length) validateCheckRunParameters();
315316

316317
["pr-url", "check-run-id", "name", "title", "summary", "text", "details-url", "conclusion"]
317318
.map((name) => [name.replaceAll("-", "_"), core.getInput(name)] as const)
@@ -336,6 +337,7 @@ export class CIHelper {
336337
check_run_id: params.check_run_id,
337338
});
338339
}
340+
core.exportVariable("STATE_check-run", JSON.stringify(params));
339341
}
340342

341343
public parsePRCommentURLInput(): { owner: string; repo: string; pull_number: number; comment_id: number } {

0 commit comments

Comments
 (0)