A trigger is an event that initiates a CI Job. The trigger event for a workflow can be specified in the workflow config file as shown in the example given below:
triggers:
- event: "pull_request_labeled"
label: "run-test"
The above config specifies that a CI Job should be triggered when a label is added to a pull request.
A workflow can have multiple triggers. Hence the triggers
config is an array. Each element of the array will have an event
attribute that specifies the trigger event. The elements should also contain any other attribute relevant to that particular trigger. In the example above, the event
is pull_request_labeled
and it also has the label
attribute that specifies the name of a label run-test
. This means that the workflow will be triggered every time the label run-test
is added{ to a pull request.
Triggers
Here's a list of triggers available in NeetoCI.
branch
This triggers a CI Job for every commit pushed to a GitHub branch.
Event Attributes
branch_name
- This specifies the branch that will be tracked for new commits.
Example
triggers:
- event: branch
branch_name: main
cron
This triggers a CI Job based on a cron schedule.
Event Attributes
branch
- This specifies the branch on which the CI Job should be run.cron_line
- This contains the cron string that specifies the schedule.
Example
triggers:
- event: cron
branch: main
cron_line: "30 3 * * *"
The above example triggers a CI Job every day at 3:30 AM.
pull_request
This triggers CI Jobs for the latest commits of all the Open Pull Requests. Whenever new commits are pushed to an open pull request or a closed pull request is reopened, a CI Job is triggered on the latest commit of that pull request.
Example
triggers:
- event: pull_request
pull_request_labeled
This triggers a CI Job when a particular label is added to a pull request.
Event Attributes
label
- This specifies the specific label whose addition should trigger a CI Job.
Example
triggers:
- event: pull_request_labeled
label: pr-ready
The above example triggers a CI Job whenever the label pr-ready
is added to a pull request.
API Trigger
Apart from all the triggers mentioned above, you can also trigger a particular workflow using an API call. Click here to learn more about the API trigger.