From 7f51d99e7cc1f147f6f99be75acf5e641930af88 Mon Sep 17 00:00:00 2001 From: Jonathan Langlois <37172224+john-jam@users.noreply.github.com> Date: Tue, 25 Oct 2022 14:25:24 +0900 Subject: [PATCH] Write the output to the $GITHUB_OUTPUT file (#17) Co-authored-by: winterjung --- main.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index 73ab22d..ed91de5 100644 --- a/main.py +++ b/main.py @@ -6,7 +6,13 @@ def set_action_output(name: str, value: str): - print(f'::set-output name={name}::{value}') + # See https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/ + path = os.getenv('GITHUB_OUTPUT') + if not path: + print_action_error('$GITHUB_OUTPUT env is required.') + exit(1) + with open(path, 'a') as github_output_file: + github_output_file.write(f'{name}={value}\n') def print_action_error(msg: str):