Skip to content

Commit

Permalink
fix: update GitHub actions step output to correctly set generated_pr
Browse files Browse the repository at this point in the history
  • Loading branch information
BilalQamar95 committed Jan 23, 2025
1 parent ea4b961 commit cfbbd93
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions edx_repo_tools/pull_request_creator/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -617,9 +617,16 @@ def _create_new_pull_request(self):
pr.number,
)
if self.output_pr_url_for_github_action:
# using print rather than logger to avoid the logger
# prepending anything past which github actions wouldn't parse
print(f'generated_pr=https://github.com/{self.repository.full_name}/pull/{pr.number} >> $GITHUB_OUTPUT')
# need to append to the special file that GitHub actions exposes
# as using print here won't set the output, it simply logs the message
github_output_path = os.environ.get("GITHUB_OUTPUT")
if not github_output_path:
logger.warning("GITHUB_OUTPUT not set, failed to write action output.")
else:
with open(github_output_path, "a", encoding="utf-8") as out_file:
out_file.write(
f"generated_pr=https://github.com/{self.repository.full_name}/pull/{pr.number}\n"
)

def delete_old_pull_requests(self):
logger.info("Checking if there's any old pull requests to delete")
Expand Down

0 comments on commit cfbbd93

Please sign in to comment.