Skip to content

event

The GitHub event name that triggers the workflow. This is the only required condition.

Type

string

Description

The event condition matches against the GitHub event that triggered the workflow. This corresponds to the event name in your workflow's on: section.

Every rule must specify an event - it's the only required condition field.

Syntax

yaml
when:
  event: pull_request  # Required

Supported Events

EventSupportDescription
pull_requestPrimaryPR opened, closed, edited, labeled, etc. Full PR context and all features.
pull_request_reviewSupportedPR review submitted, edited, dismissed. Full PR context extracted from payload.
issuesSupportedIssue opened, closed, labeled, etc. Full issue context and task creation.
pull_request_target⚠️ LimitedSimilar to pull_request but runs in base branch context.
push❌ UnsupportedNo PR or issue context available.
issue_comment❌ UnsupportedNo PR or issue context available.

TIP

pull_request, pull_request_review, and issues are the supported events. All provide full context and support all relevant features. The action returns early with a warning for any other event type.

For a complete list of GitHub events, see:

Examples

PR Event

Match any pull request event:

yaml
rules:
  - when:
      event: pull_request
    then:
      update_fields:
        '1234567890': 'In Progress'

PR Review Event

Update an Asana field when a pull request review is submitted:

yaml
rules:
  - when:
      event: pull_request_review
      action: submitted
      review_state: approved
    then:
      update_fields:
        '1234567890': 'Code Approved'

Issues Event

Create an Asana task when a GitHub issue is opened:

yaml
rules:
  - when:
      event: issues
      action: opened
      has_asana_tasks: false
    then:
      create_task:
        project: '1234567890'
        workspace: '0987654321'
        title: 'GH Issue #{{issue.number}}: {{issue.title}}'
        notes: '{{issue.body}}'

Workflow Configuration

The event in your rule must match an event in your workflow's on: section. To handle PRs, PR reviews, and issues, listen for all relevant events:

yaml
# .github/workflows/asana-sync.yml
on:
  pull_request:
    types: [opened, closed, labeled, reopened, ready_for_review]
  pull_request_review:
    types: [submitted, edited, dismissed]
  issues:
    types: [opened, closed, labeled, reopened]

jobs:
  sync:
    runs-on: ubuntu-latest
    steps:
      - uses: planningcenter/asana-github-sync@main
        with:
          asana_token: ${{ secrets.ASANA_TOKEN }}
          github_token: ${{ github.token }}
          rules: |
            rules:
              - when:
                  event: pull_request
                  action: opened
                  draft: false
                then:
                  update_fields:
                    '1234567890': 'In Review'

              - when:
                  event: issues
                  action: opened
                  has_asana_tasks: false
                then:
                  create_task:
                    project: '1234567890'
                    workspace: '0987654321'
                    title: 'Issue #{{issue.number}}: {{issue.title}}'

Combining with Other Conditions

Use additional conditions to be more specific:

yaml
rules:
  # PR-specific conditions
  - when:
      event: pull_request
      action: opened
      draft: false             # PR-only condition
    then:
      update_fields:
        '1234567890': 'In Review'

  # Issue-specific rule
  - when:
      event: issues
      action: opened
      has_asana_tasks: false
    then:
      create_task:
        project: '1234567890'
        workspace: '0987654321'
        title: '{{issue.title}}'

PR-only conditions

The merged and draft conditions are PR-only — they will never match on an issues event, even if specified.

Validation Rules

  • Required: Every rule must have an event
  • Type: Must be a string
  • Case-sensitive: Use lowercase (e.g., pull_request, not Pull_Request)

Common Errors

Missing event

yaml
# ❌ Wrong - no event specified
when:
  action: opened
then:
  # ...

# ✅ Correct
when:
  event: pull_request
  action: opened
then:
  # ...

Wrong event name

yaml
# ❌ Wrong - workflow doesn't listen for 'push'
on:
  pull_request:

rules:
  - when:
      event: push  # This will never match!
    then:
      # ...

See Also

Released under the MIT License.