JavaScript Execution
Aviator allows for executing custom JS code with Pilot automated actions or the MergeQueue ready hook. Learn more details about how it happens in our guide.
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 aviatorRepresents 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:
aviator.github.addLabel({ label: "urgent", target: event.pullRequest.id });or
$aviator.mergequeue.synchronizePullRequest({target: event.pullRequest.id});$github
$githubCorresponds to the GitHub component, and can also be used directly. Example:
$github.addLabel({ label: "urgent", target: event.pullRequest.id });$slack
$slackCorresponds to the Slack component and can also be used directly. Example:
$slack.channel({text: "A reset was caused by PR#" + event.pullRequest.number })$mergequeue
$mergequeueCorresponds to the MergeQueue component, and can be used directly. Example:
$mergequeue.copyPullRequest({branch: "c/" + event.pullRequest.head.ref})console
consoleRepresents 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
PullRequestEventAssociated with a pull_request trigger. It has a the following properties:
event.pullRequest- aPullRequestobjectevent.action- string representing the action on the pull request.event.sender- aGitHubUserobject representing the user who took the action on the pull requestevent.repository- aGitHubrepository object
PullRequestReviewEvent
PullRequestReviewEventAssociated with a pull_request_review trigger. It has the following properties:
event.pullRequest- aPullRequestobjectevent.action- string representing the action on the pull request.event.sender- aGitHubUserobject representing the user who took the action on the pull requestevent.repository- aGitHubRepositoryobjectevent.review- aReviewobject
MergeQueueEvent
MergeQueueEventAssociated with a merge_queue trigger. It has the following properties:
event.pullRequest- aPullRequestobjectevent.action- string representing the action on the pull requestevent.repository- aGitHubRepositoryobject
Event Objects
PullRequest
url- string representing the URL of the pull request. E.g.https://github.com/aviator-co/mergeit/pull/6301number- integer representing PR number, e.g.:6301state- string representing state of the PR, possible values:open,pending,queued,blockedandmergeduser- aGitHubUserobject 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#6301base- aPullRequestRefobject representing the base branch of this PR.head- aPullRequestRefobject 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.mergeitfullName- string representing the org name and repository name together, e.g.aviator-co/mergeit
Review
user- TheGithubUserwho submitted the reviewbody- string representing the contents of the reviewstate- string representingapproved, changes_requested, commented
Last updated
Was this helpful?
