Skip to content

Commit

Permalink
Update GH set output
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleJamesWalker authored Mar 25, 2024
1 parent ce65396 commit b5d4c14
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions pr_changes/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
import fnmatch
import hashlib
import json
import os
import re
import sys

from typing import List, Dict
from pr_changes.config import get_config
Expand Down Expand Up @@ -61,9 +63,15 @@ def generate_matrix(changes: List[str]) -> Dict:


def set_output(name: str, value: object) -> None:
"""Set an action output via stdout."""
"""Set an action output via environment file."""
json_text = json.dumps(value)
print(f"::set-output name={name}::{json_text}")
output_fn = os.getenv("GITHUB_OUTPUT")
output_file = open(os.getenv("GITHUB_OUTPUT"), "a") if output_fn else sys.stdout
output_file.write(f"{name}={json_text}\n")

# Only close the file it it's not stdout
if output_fn:
output_file.close()


def include_file(fn: str) -> bool:
Expand Down

0 comments on commit b5d4c14

Please sign in to comment.