import { Workflow } from "https://deno.land/x/actionify@0.3.0/mod.ts";
To automatically trigger a workflow, use on to define which events can cause the workflow to run. For a list of available events, see "Events that trigger workflows."
You can define single or multiple events that can a trigger workflow, or set a time schedule. You can also restrict the execution of a workflow to only occur for specific files, tags, or branch changes. These options are described in the following sections.
Using a single event
For example, a workflow with the following on value will run when a push is made to any branch in the workflow's repository:
import { workflow } from 'https://deno.land/x/actionify@0.3.0/mod.ts';
const ci = workflow({ name: 'ci' })
.on('push');
Using multiple events
You can specify a single event or multiple events. For example, a workflow with the following on value will run when a push is made to any branch in the repository or when someone forks the repository:
import { workflow } from 'https://deno.land/x/actionify@0.3.0/mod.ts';
const ci = workflow({ name: 'ci' })
.on('push')
.on('fork');
If you specify multiple events, only one of those events needs to occur to trigger your workflow. If multiple triggering events for your workflow occur at the same time, multiple workflow runs will be triggered.
Using activity types
Some events have activity types that give you more control over when your workflow should run. Use on.<event_name>.types to define the type of event activity that will trigger a workflow run.
For example, the issue_comment event has the created, edited, and deleted activity types. If your workflow triggers on the label event, it will run whenever a label is created, edited, or deleted. If you specify the created activity type for the label event, your workflow will run when a label is created but not when a label is edited or deleted.
import { workflow } from 'https://deno.land/x/actionify@0.3.0/mod.ts';
const ci = workflow({ name: 'ci' })
.on('push')
.on('label', { types: ['created'] });
If you specify multiple activity types, only one of those event activity types needs to occur to trigger your workflow. If multiple triggering event activity types for your workflow occur at the same time, multiple workflow runs will be triggered. For example, the following workflow triggers when an issue is opened or labeled. If an issue with two labels is opened, three workflow runs will start: one for the issue opened event and two for the two issue labeled events.
import { workflow } from 'https://deno.land/x/actionify@0.3.0/mod.ts';
const ci = workflow({ name: 'ci' })
.on('push')
.on('pull_request', { types: ['opened', 'labeled'] });
For more information about each event and their activity types, see "Events that trigger workflows."