JavaScript Execution
Aviator has support for executing custom JavaScript code using Pilot automated actions or the MergeQueue ready hook.
For security and sandboxing purposes, The Pilot JavaScript execution does not provide most standard web APIs (such as fetch
). Instead, several integrations with MergeQueue, GitHub, and Slack are provided.
Each Javascript code execution has maximum time limit of 10 seconds, and you can write arbitrary javascript within the bounds of provided APIs and context.
Global Context
For each Javascript execution, Aviator provides the a few variables for global context. These variables can be used to query data or take action.
$aviator
or aviator
$aviator
or aviator
Represents the top level context. It has 3 properties: github
, slack
and mergequeue
. These properties can also be used directly with $github
, $slack
and $mergequeue
respectively. Example:
or
$github
$github
Corresponds to the GitHub component, and can also be used directly. Example:
$slack
$slack
Corresponds to the Slack component and can also be used directly. Example:
$mergequeue
$mergequeue
Corresponds to the MergeQueue component, and can be used directly. Example:
console
console
Represents the standard javascript console. Although these console logs are not captured anywhere.
Local Context
For each Javascript execution, Aviator also provides a local context associated with the trigger that caused the javascript to be executed. This is defined as event
object. An event can be of multiple types. Each trigger event represents one even type:
PullRequestEvent
PullRequestEvent
Associated with a pull_request
trigger. It has a the following properties:
event.pullRequest
- aPullRequest
objectevent.action
- string representing the action on the pull request.event.sender
- aGitHubUser
object representing the user who took the action on the pull requestevent.repository
- aGitHub
repository object
PullRequestReviewEvent
PullRequestReviewEvent
Associated with a pull_request_review
trigger. It has the following properties:
event.pullRequest
- aPullRequest
objectevent.action
- string representing the action on the pull request.event.sender
- aGitHubUser
object representing the user who took the action on the pull requestevent.repository
- aGitHubRepository
objectevent.review
- aReview
object
MergeQueueEvent
MergeQueueEvent
Associated with a merge_queue
trigger. It has the following properties:
event.pullRequest
- aPullRequest
objectevent.action
- string representing the action on the pull requestevent.repository
- aGitHubRepository
object
Event Objects
PullRequest
url
- string representing the URL of the pull request. E.g.https://github.com/aviator-co/mergeit/pull/6301
number
- integer representing PR number, e.g.:6301
state
- string representing state of the PR, possible values:open
,pending
,queued
,blocked
andmerged
user
- aGitHubUser
object representing the author of the PRskipLine
- boolean. True when the PR is a skip-line label (associated with MergeQueue)skipLineReason
- string (optional). If skip line reason was providedid
- representing a unique identifier for a pull request. e.g.aviator-co/mergeit#6301
base
- aPullRequestRef
object representing the base branch of this PR.head
- aPullRequestRef
object representing the head branch of this PR.
PullRequestRef
ref
- string representing a branch, e.g.master
GitHubUser
login
- string representing the GitHub username
GitHubRepository
name
- string representing the name of the repository, e.g.mergeit
fullName
- string representing the org name and repository name together, e.g.aviator-co/mergeit
Review
user
- TheGithubUser
who submitted the reviewbody
- string representing the contents of the reviewstate
- string representingapproved, changes_requested, commented
Last updated