mirror of
https://github.com/zulip/zulip.git
synced 2025-10-23 04:52:12 +00:00
Using curl to POST to the CircleCI workflow endpoint on CZO: - Doesn't work on zulip/zulip@main (CZO runs a revert) - Sets a bad example for other orgs - Robs us of an opportunity to dogfood our own zulip/github-actions-zulip Refactor the Actions workflows in this repo to report failure states using the Zulip Action, and reimplement the related helper scripts in Python, since they'd previously mostly shelled out to Python anyway.
23 lines
754 B
Python
Executable File
23 lines
754 B
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
import os
|
|
|
|
|
|
def get_build_url_from_environment() -> str:
|
|
server = os.environ["GITHUB_SERVER_URL"]
|
|
repo = os.environ["GITHUB_REPOSITORY"]
|
|
run_id = os.environ["GITHUB_RUN_ID"]
|
|
return f"{server}/{repo}/actions/runs/{run_id}"
|
|
|
|
|
|
if __name__ == "__main__":
|
|
branch = os.environ.get("GITHUB_REF", "unknown branch").split("/")[-1]
|
|
topic = f"{branch} failing"
|
|
build_url = get_build_url_from_environment()
|
|
github_actor = os.environ.get("GITHUB_ACTOR", "unknown user")
|
|
content = f"[Build]({build_url}) triggered by {github_actor} on branch `{branch}` has failed."
|
|
|
|
# Output in the key-value pair format GitHub Actions outputs are expected
|
|
# to be in.
|
|
print(f"topic={topic}\ncontent={content}")
|