Allow jobs on forks which have self hosted runners setup.

Signed-off-by: Pedro Algarvio <palgarvio@vmware.com>
This commit is contained in:
Pedro Algarvio 2023-03-07 21:15:29 +00:00 committed by Pedro Algarvio
parent d64b74ff91
commit 2e3b27e775

View file

@ -196,7 +196,10 @@ def runner_types(ctx: Context, event_name: str):
# This is a push or a scheduled event
ctx.info(f"Running from a {event_name!r} event")
if gh_event["repository"]["fork"] is True:
if (
gh_event["repository"]["fork"] is True
and os.environ.get("FORK_HAS_SELF_HOSTED_RUNNERS", "0") == "1"
):
# This is running on a forked repository, don't run tests
ctx.info("The push event is on a forked repository")
runners["github-hosted"] = True
@ -205,7 +208,7 @@ def runner_types(ctx: Context, event_name: str):
wfh.write(f"runners={json.dumps(runners)}\n")
ctx.exit(0)
# Not running on a fork, run everything
# Not running on a fork, or the fork has self hosted runners, run everything
ctx.info(f"The {event_name!r} event is from the main repository")
runners["github-hosted"] = runners["self-hosted"] = True
ctx.info("Writing 'runners' to the github outputs file")