819 introduced a very powerful mechanism to control things within a build. Let's build on top of it even more powerful mechanism like repository hooks.
The idea here is to create builds for a given repository based on arbitrary events.
def on_github_event(ctx):
pr_base_change_event = ctx.event == "pull_request" && ctx.payload.action == "edited" && ctx.payload.changes.base is not None
if not pr_base_change_event:
return
# this will create a new build for the PR
return {
"status": "CREATED", # can be TRIGGERED but then should have non empty `tasks` field with the tasks.
"branch": "pull/{}".format(payload.number),
"changeIdInRepo": payload.head.sha, # optional, by default can be the latest of `branch`
"message": "PR base was changed",
}
Additionally we can allow injesting custom events. For example, posting to https://api.cirrus-ci.com/github/my-org/my-repo/events/SOURCE will trigger on_SOURCE_event function from .cirrus.star which can create a build.
Description
819 introduced a very powerful mechanism to control things within a build. Let's build on top of it even more powerful mechanism like repository hooks.
The idea here is to create builds for a given repository based on arbitrary events.
Context
Here is a rough idea:
For example, we can automate re-triggering/re-creating of a build when a base branch for a PR is changed:
Additionally we can allow injesting custom events. For example, posting to
https://api.cirrus-ci.com/github/my-org/my-repo/events/SOURCE
will triggeron_SOURCE_event
function from.cirrus.star
which can create a build.