GitHub Pull Request Trigger

See related documentation on getting started with GitHub and on event triggers.

Placing the following snippet at the top of an RWX file will result in all tasks in the file running any time a GitHub pull request is opened, reopened, or updated (synchronize).

on:
  github:
    pull_request:

It's common to pass values from the event as init parameters into tasks.

on:
  github:
    pull_request:
      init:
        commit-sha: ${{ event.git.sha }}

base:
  os: ubuntu 24.04
  tag: 1.2

tasks:
  - key: code
    call: git/clone 1.6.10
    with:
      repository: https://github.com/YOUR_ORG/PROJECT.git
      ref: ${{ init.commit-sha }}
      github-access-token: ${{ github.token }}

Pull Request Closed

You may also want to run tasks when pull requests are closed, which you can do by specifying actions: [closed].

on:
  github:
    pull_request:
      actions: [closed]

When a pull request is closed, ${{ event.git.sha }} may point to a commit that no longer exists and cannot be cloned. This can happen based on your merge strategy, like if you're using squash and merge. It can also happen if you close the PR without merging and have GitHub configured to delete the branch.

If you need to clone the repository to use a script within it, you should clone from a default branch. This is necessary to execute the logic that you want to run when pull requests are closed. It's common to clone from a default branch, such as main, instead of cloning the PR commit.

on:
  github:
    pull_request:
      actions: [closed]

base:
  os: ubuntu 24.04
  tag: 1.2

tasks:
  - key: code
    call: git/clone 1.6.10
    with:
      repository: https://github.com/your-org/your-repo.git
      ref: main # use scripts from from main since the PR commit gets deleted on close
      github-access-token: ${{ github.token }}

Event Fields

The following fields are available on GitHub Pull Request events.

attributedescription
event.git.branchThe pull request branch
event.git.shaThe commit sha of the head of the pull request
event.git.refThe fully qualified ref of the pull request branch, which always starts with refs/heads/
event.github.pull_request.numberThe pull request number
event.github.pull_request.pull_request.titleThe pull request title

For the full set of attributes available within event.github.pull_request, see GitHub's documentation on pull request webhooks

Actions

By default, RWX fires the pull request trigger on [opened, reopened, synchronze]. If you only want to handle certain actions, you can specify them:

on:
  github:
    pull_request:
      actions: [opened]
actiondescription
openedA pull request is opened. Depending on your use, you may also want to include reopened.
reopenedA previously opened pull request is opened again.
synchronizeThe pull request’s tracking branch is synchronized with the source branch for the pull request, which happens when the source branch is updated.
closedA pull request is closed.