Event Triggers

Mint can trigger runs based on certain events. Currently, GitHub push and pull_request events are supported.

Run on GitHub Push

Before configuring Mint to run on GitHub pushes, ensure you've followed the getting started with GitHub guide.

Placing the following snippet at the top of a Mint file will result in all tasks in the file running on every GitHub push.

on:
  github:
    push:

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

on:
  github:
    push:
      init:
        commit-sha: ${{ event.github.push.head_commit.id }}

tasks:
  - key: code
    call: mint/git-clone 1.1.4
    with:
      repository: [email protected]:YOUR_ORG/PROJECT.git
      ref: ${{ init.commit-sha }}
      github-access-token: ${{ secrets.YOUR_ORG_CLONE_TOKEN }}

For all values available via the event.github.push context, see the GitHub Push Trigger reference.

Run on GitHub Pull Request

Before configuring Mint to run on GitHub pull requests, ensure you've followed the getting started with GitHub guide.

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

on:
  github:
    pull_request:
      actions: [opened, reopened, synchronize]

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

on:
  github:
    pull_request:
      actions: [opened, reopened, synchronize]
      init:
        commit-sha: ${{ event.github.pull_request.pull_request.head.sha }}

tasks:
  - key: code
    call: mint/git-clone 1.1.4
    with:
      repository: [email protected]:YOUR_ORG/PROJECT.git
      ref: ${{ init.commit-sha }}
      github-access-token: ${{ secrets.YOUR_ORG_CLONE_TOKEN }}

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

For all values available via the event.github.pull_request context, see the GitHub Pull Request Trigger reference.

Actions

actiondescription
openedA pull request is opened. Depending on your use, you may also want to include reopened.
reopenedA previously opened pull request is reopened.
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.

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 is 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]

Multiple Triggers

You can configure multiple triggers in a single file by passing them as an array. Mint 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, presently 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 conditionally trigger a new run in response to an event. For example, if you only want your definition to be triggered on pushes to main:

on:
  github:
    push:
      if: ${{ mint.run.git.branch == 'main' }}
      init:
        commit-sha: ${{ event.github.push.head_commit.id }}