Control flow

Edit this page

Learn how to control the flow of Workflows with conditions that run certain jobs based on the result of previous jobs.


You can control the flow of your workflows with conditions that run certain jobs based on the result of previous jobs.

needs

You can add a list of previous job names using the needs keyword on a job. If any job from that list fails, the current job will be skipped.

.eas/workflows/prerequisite.yaml
jobs:
  build:
    type: build
    params:
      platform: ios
      profile: production
  end-to-end-test:
    needs: [build]
    type: maestro
    params:
      build_id: ${{ jobs.build.outputs.build_id }}
      flow_path: ['./e2e/flow.yaml']

after

You can add a list of previous job names using the after keyword on a job. Any job in the list will run after the current job completes, no matter if it succeeded or failed.

.eas/workflows/after.yaml
jobs:
  build:
    type: build
    params:
      platform: ios
      profile: production
  send_slack_notification:
    after: [build]
    steps:
      - name: Send Slack notification
        inputs:
          message: 'Build completed.'
          slack_hook_url: ${{ secrets.SLACK_WEBHOOK_URL }}

if

You can add a condition to a job with the if keyword. If the condition evaluates to true, the job will run. Otherwise, it will be skipped.

.eas/workflows/conditional.yaml
on:
	push: {} # runs on all branches

jobs:
  update:
    type: update
  build:
    name: Build iOS
    type: build
    if: ${{ github.ref == "refs/heads/main" }} # Will only run if on main.
    params:
      profile: production
      platform: ios