Event Triggers
RWX can trigger runs based on certain events from GitHub or GitLab.
GitHub Event Triggers
Before configuring RWX to run on GitHub events, ensure you've followed the getting started with GitHub guide.
GitLab Event Triggers
Title
You can override the default title of your run by specifying the title. It accepts an expression and can use the
mint, event, and init contexts. For example:
on:
github:
push:
title: 'CI: ${{ event.github.push.head_commit.message}}'
Or:
on:
github:
pull_request:
title: 'CI for PR #${{ event.github.pull_request.number }}'
Target
If you only want to run certain tasks on the event, you can specify a target under any trigger.
Here's an example of specifying a target on a push event, but you can also specify targets for pull_request events.
on:
github:
push:
target: task-key-to-run
If you want to target multiple tasks, pass them as an array.
on:
github:
push:
target: [task-key1, task-key2]
Start Manually
When a trigger is fired, by default RWX will automatically start a run. However, you may want to create it in a waiting state, so that you can manually start it. You can do this by specifying start: manually.
on:
github:
push:
start: manually
Multiple Triggers
You can configure multiple triggers in a single file by passing them as an array. RWX will create one run per trigger.
on:
github:
push:
- target: task-key-to-target
init:
param-to-set: value1
- target: task-key-to-target
init:
param-to-set: value2
Because you can specify multiple tasks to target on a single trigger, the only reason to have multiple triggers is to have different init params.
It's rare to need this, but it's supported.
Conditional Triggers
Triggers can specify if to trigger a new run conditionally in response to an event. For example, if you only want your definition to be triggered on pushes to main:
on:
github:
push:
if: ${{ event.git.branch == 'main' }}
init:
commit-sha: ${{ event.git.sha }}
Paths
You may want to configure your CI workflow to only run when certain file paths change.
With RWX, this may not be necessary. If you have a filter on your task, it will be cached if the files listed in the filter do not change.
However, you may still have reasons for wanting to selectively run tasks.
If so, you can use the github/compare package.
The documentation for the package shows examples of checking the diff for both push and pull request triggers.