Task¶
# yaml-language-server: $schema=https://saturn-bot.readthedocs.io/en/latest/schemas/task.schema.json
name: "Saturn Hello World"
prTitle: "Saturn Hello World"
prBody: |
Saturn Quickstart.
This pull request creates the file `hello-world.txt`.
# Repository filters allow targeting specific repositories.
repositories:
- host: codeberg.org # Replace with your host
owner: saturn-sync # Replace with your owner
name: saturn-example # Replace with your repository
# Add one or more script commands to modify a repository.
script:
- echo "Hello World" > hello-world.txt
active¶
Set to false to temporarily deactivate the task and prevent it from executing.
Examples
afterScript¶
One or more script commands that are executed after the "script" commands.
If any command exits with an exit code != 0,
Saturn does not consider the execution as failed.
Saturn sets all environment variables listed in script plus the following environment variables:
| Name | Description | Example |
|---|---|---|
ACTION |
Action that Saturn took. | See below |
PULL_REQUEST_URL |
URL of the pull request managed by Saturn. | https://codeberg.org/saturn-sync/saturn/pulls/168 |
Value of ACTION¶
Use ACTION, for example, to send a message when Saturn creates a pull request.
ACTION can have one of the following values:
| Value | Description |
|---|---|
closed |
Saturn closed the pull request. |
created |
Saturn created the pull request. |
merged |
Saturn merged the pull request. |
pushed |
Saturn pushed changes to the default branch. |
<empty> |
Saturn did not take any action. |
Examples
script:
- echo "example" > example.txt
afterScript:
- |
if [[ "$ACTION" == "created" ]]; then
echo "Please take a look at $PULL_REQUEST_URL." | mail -s "New pull request for $REPOSITORY" team@example
fi
assignees¶
A list of usernames to set as assignees of a pull request.
Note
If the task previously defined assignees and the list is set back to empty then Saturn doesn't remove the assignees from a pull request.
Note
Bitbucket does not support assignees.
Examples
autoCloseAfter¶
Automatically close a pull request if it has been unmerged for the duration. Format is seconds. Set to 0, the default, to deactivate.
Examples
autoMerge¶
Merge a pull request automatically if all checks have passed and all approvals have been given.
Examples
autoMergeAfter¶
If set, automatically merge the pull request after it has been open for the specified amount of time. Only applied if autoMerge is true. The value is a Go duration, like 5m or 1h.
Examples
autoMergeWindow¶
Allow auto-merging of pull requests within the given window. Only has an effect if autoMerge=true.
This setting allows more fine-grained control over when Saturn auto-merges pull requests. It makes it possible to, for example, run Saturn regularly during the day and the night but limit auto-merging to business hours.
Examples
autoMerge: true
autoMergeWindow: between 9:00 and 16:00 from Monday to Thursday
Uses wandhydrant/go-human-timerange to parse the value. Please read the documentation of the library to learn how to write the statement.
autoMergeWindowTimeZone¶
The time zone to use when checking the autoMergeWindow. Defaults to the time zone of the system if unset.
Useful if the server(s) that execute Saturn use a different time zone than the users that write the tasks.
For a list of time zones, see List of tz database time zones.
Examples
autoMerge: true
autoMergeWindow: between 9:00 and 16:00 from Monday to Thursday
autoMergeWindowTimeZone: Europe/Brussels
branchName¶
If set, used as the name of the branch to commit changes to. Defaults to an auto-generated name if not set.
Supports templating.
Some git hosts restrict the maximum length of branch names. The branch name is automatically cut to 230 characters.
Examples
changeLimit¶
Number of pull requests to create or merge (combined) in one run. Useful to reduce strain on a system caused by, for example, many CI/CD jobs created at the same time.
commitMessage¶
The message to use when committing changes. Defaults to changes by Saturn if not set.
Supports templating.
Examples
createOnly¶
Create pull requests only. Don't attempt to update a pull request on a subsequent run.
inputs¶
Inputs allows customizing a task at runtime.
Inputs provides more details on how to use them.
keepBranchAfterMerge¶
If true, keep the branch after a pull request has been merged.
labels¶
List of labels to attach to a pull request.
Forgejo
Forgejo does not create labels on-demand. If a label does not exist, then it will not be added to a pull request. The documentation on labels describes how to add labels.
maxOpenPRs¶
The number of pull requests that can be open at the same time. 0 disables the feature.
mergeOnce¶
If true, no new pull request is being created if a previous pull request has been merged for this task.
metricLabels¶
Key/value pairs to add as custom labels to the metric sb_server_task_run_success. Only available in server mode.
name¶
The name of the task. Used as an identifier.
prBody¶
If set, used as the body of the pull request.
Supports templating.
Examples
prBodyPlain¶
If true, Saturn does not append additional text, such as the "... created by Saturn ..." message, to the end of the description of a pull request.
This option removes any hint that Saturn was used by the user to create the pull request from the description of a pull request.
Note
Activating this option turns off the "check this box to rebase" functionality.
Examples
prTitle¶
If set, used as the title of the pull request.
Supports templating.
Examples
pushToDefaultBranch¶
If true, push changes directly to the default branch, like "main". If false, create a pull request to submit changes.
Defaults to false.
Examples
repositories¶
One or more filters to match repositories.
Saturn, by default, applies a task to all repositories it has access to. Repository filters allow targeting specific repositories, such as those owned by a specific organization or group.
Repository filters support with gradually rolling out a change to a few repositories before rolling it out across all repositories. Repository filters can also reduce the runtime of each task and load on a Git host because Saturn has to clone fewer repositories.
The value of host, owner and name is a regular expression.
Each value is automatically enclosed with ^ and $.
Examples
repositories:
- host: "github.com"
owner: "octocat"
name: ".*"
repositories:
- host: "github.com"
owner: "octocat"
name: "api-.*"
repositories:
- host: "github.com"
owner: "octocat"
name: ".*"
- host: "github.com"
owner: "octocat"
name: "Hello-World"
reverse: true
reviewers¶
A list of usernames to set as reviewers of the pull request.
Note
If the task previously defined reviewers and the list is set back to empty then Saturn doesn't remove the reviewers from a pull request.
Examples
script¶
One or more script commands to modify the content in a repository.
If any command exits with an exit code != 0,
Saturn considers the execution as failed.
Saturn sets the following environment variables:
| Name | Description | Example |
|---|---|---|
INPUT_<name> |
Values of one of the inputs of the task. | INPUT_greeting |
REPOSITORY |
Full name of the repository. | codeberg.org/saturn-sync/saturn |
REPOSITORY_HOST |
Host of the repository. | codeberg.org |
REPOSITORY_OWNER |
Owner of the repository. | saturn-sync |
REPOSITORY_NAME |
Name of the repository. | saturn |
TASK |
Name of the current task. | Hello World |
TASK_SLUG |
Sluggified version of the name of the current task. | hello-world |
TASK_DIR |
Path to the directory that contains the current task file. | /tasks |
Examples
scriptShell¶
Path to the shell to execute the script. Searches $PATH if the value isn't an absolute path.
Examples
script:
- echo "example" > example.txt
scriptShell: "bash"
script:
- echo "example" > example.txt
scriptShell: "/bin/bash"
scriptTimeout¶
Maximum time a script is allowed to run, in Go duration notation. Defaults to 1m.
Note
The timeout is per script execution. Saturn executes the script in a new process for each repository. If Saturn tries to modify 5 repositories, then it executes the script 5 times and each execution has its own timeout.
Examples
trigger¶
Define when the task gets executed. Only relevant in server mode.
changes¶
Schedule a new run whenever the content of the task file and, optionally, additional files change.
The server automatically schedules a new run the first time it discovers the task.
trigger:
changes:
active: true
files: ["*.json"]
active¶
Activate scheduling on changes. Defaults to false.
files¶
List of additional files to consider. If one of the files changes, a new run will be scheduled. The path of each file can be a path relative to the task file or an absolute path. Supports globbing.
cron¶
Trigger the task based on a cron schedule.
crontab.guru supports with writing the cron schedule expression.
webhook¶
Execute the task when the server receives a webhook.
Trigger a task when a webhook is received describes how to set up a webhook.
See Webhook for reference.
delay¶
Delay the execution of the task, in seconds, after the webhook has been received by the server.