Pilot Automated Actions
Aviator offers automated actions that can be configured via the configuration file to perform specific actions depending on a particular event or scenario. You can write your own custom scenarios and corresponding actions in the configuration file.
Each Pilot workflow contains one scenario and one or more actions. Here’s an example of a simple scenario:
In the above example, we are triggering an instant merge action based on the label av-instant-merge
.
Scenarios
A scenario is a configurable, automated process that is invoked in response to a certain trigger and which in turn may run several actions. Scenarios are often phrased in English as “if this, then that.”
In the configuration file, the scenarios object has three properties
name
- a readable name that uniquely identifies a particular scenariotrigger
- represents an object and an associated event that will trigger this scenarioactions
- a list of actions that will be triggered in order when the trigger scenario condition is met.
Triggers
Each trigger is associated with a context of an object. Currently we support the following types of contexts:
pull_request
It has the following associated events:
opened: represents when the PR is opened
labeled: when a GitHub label is added to the PR
You can also specify who labeled the PR or who the author is. Here a GitHub username can be provided. If you want to instead represent a team, you can use @org/team
. Exactly one of github_login
and github_team
must be specified.
synchronize: The PR was synchronized. This means that the pull request either had new commits pushed to it, was force-pushed, or had its base branch changed.
submitted: The PR is ready for review.. This means that it was either opened, or switched from draft to ready for review.
Note that both submitted and opened events will be triggered when a PR is directly opened in review mode (as non-draft).
pull_request_review
Associated events:
approved: The PR review provided was of approved type.
mergequeue
Associated events:
ready: A user requested a PR to be queued. This is triggered at the same time as the
pullrequest.labeled
action if the PR was queued using a GitHub label.
queued: A PR was added to the queue.
skip_line [optional]: A PR marked to skip the line was added to the queue.
To add the skip_line option:
added_to_batch: A PR was added to batch for validation. This is applicable only for parallel mode. This will still be called even if the draft PR was skipped due to
skip_draft_when_up_to_date
config setting in the parallel mode.
removed_from_batch: A PR was removed from the validation batch. This is applicable only for parallel mode. This will still be called even if the draft PR was skipped due to
skip_draft_when_up_to_date
config setting in the parallel mode.
top_of_queue: A new PR reached the top of the queue.
merged: A PR was merged.
blocked: A PR was blocked by Aviator.
stuck: A PR was marked as stuck by Aviator.
reset: The queue was reset.
schedule
Used to trigger scheduled events. Please read Scheduled Events for examples.
cron_utc - required string parameter. Accepts a unix cron format. You can use a cron visual tool like crontab.guru for building your cron string.
Actions
You can specify one or more actions to be executed based on the triggers specified in the scenarios. These actions are performed serially in the order specified and are executed in the context of the trigger. For instance, if we specify the labeled
event for a pull_request
in the trigger, then the associated action can be performed on the same PR that was labeled.
There are a few types of actions.
github
These include actions to add a label or add a reviewer.
add_label - Add a GitHub label to the PR. You can directly pass it the label name.
remove_label - Remove the provided GitHub label from the PR. If the label doesn't exist, this action will be a no-op.
add_reviewer - Add a reviewer to the PR. You can directly pass the username or a team name (
@org/team
) as a parameter to this action.
mergequeue
Used to interact with Aviator’s merge queue. The queue
action will enqueue the PR and instant_merge
will merge the PR instantly. You can read more about instant merge behavior here.
There's also the ability to pause
and unpause
. By default, the entire repository (including all base branches) will be paused/unpaused.
You can also specify a branch_pattern
or a paused_message
, both of these fields are optional.
slack
Send a Slack notification to the connected Slack account. Note that this requires Slack integration to be active.
channel: Send notification to a Slack channel.
text: The text to send in the notification.
hook_url [optional]: The webhook URL for a Slack channel. If not provided, the default channel set up with the Slack integration will be used.
direct: Send a Slack DM to a user directly.
text: The text to send in the notification.
blocks [optional]: Customized Slack blocks to send in the notification. See Slack's block building kit.
github_users [optional]: The GitHub users to notify (must be the GitHub username associated with the user). If not specified, the notification will be sent to the author of the PR.
github_group [optional]: The GitHub group whose members will be notified.
labels [optional]: Labels associated with this Slack DM that users can utilize to personalize DMs. By default, all specified users (either
github_users
,github_group
, or the author of the PR will be notified). If you want to opt-out, see Personal Integrations.opt-in [optional]: If True, then the users will need to voluntarily opt-in to receive the DM.
script
If you want more custom controls over the actions, you may also choose to write a custom script using Javascript. All the other actions described above can be triggered via script as well. Here’s a quick example:
The following attributes are accessible via the event
variable.
pullRequest
url: The URL of the pull request.
number: The number of the pull request. (ex.
event.pullRequest.number
)state: The state of the pull request. If the trigger is a
pull_request
trigger, options are:open
,closed
. If the trigger is amergequeue
trigger, options are:open
,queued
,blocked
,merged
,tagged
.labels: Labels that are on the pull request.
user
login: The GitHub login of the user who opened the pull request.
skipLine (
mergequeue
trigger only): [boolean] Whether the pull request was queued with skip line.skipLineReason (
mergequeue
trigger only): The skip line reason for a pull request if it was given. (ex.event.pullRequest.skipLineReason
)
repository
name: The name of the repository. (ex.
event.repository.name
)full_name: The full name of the repository, including the organization name, in the format
org/repo_name
.
Last updated