Skip to main content
In this guide, we’ll dive into advanced expression syntax for GitHub Actions to build more flexible CI/CD pipelines. You’ll learn how to:
  • Control step and job execution with if conditions
  • Allow workflows to continue after failures using continue-on-error
  • Inspect outcomes with status-check functions (success(), failure(), etc.)
Before we explore expressions, let’s review a sample workflow to see common pitfalls.

Sample Workflow Overview

Jobs Breakdown
  1. testing: Runs tests on both Windows and Ubuntu, setting an apikey.
  2. reports: Uploads test results to AWS S3 and deliberately fails.
  3. deploy: Depends on the reports job.
Because the Ubuntu runner uses Bash’s export (and PowerShell commands won’t execute on Linux), the testing job fails for one matrix entry, blocking all downstream jobs.
Storing secrets directly in your workflow can expose them in logs. Use GitHub Secrets instead.

Core Expressions in GitHub Actions

Expressions let you dynamically control when a step or job runs. There are three main categories:
  1. Conditional execution with if
  2. Error handling with continue-on-error
  3. Status inspection functions (success(), failure(), etc.)

1. Conditional Execution with if

Use if to evaluate expressions based on contexts, comparisons, and built-in functions:
  • runner.os, github.ref, and other contexts provide metadata.
  • Combine expressions using &&, ||, ==, !=, and functions.

2. Allowing Failures with continue-on-error

By default, a failed step stops its job. Enable continue-on-error to proceed even if a step or job fails:
Use continue-on-error carefully—it can mask genuine failures if overused.

3. Status Check Functions

Inspect the results of prior steps or jobs with these functions: Example usage:

Fixing the Sample Workflow

Let’s apply these expressions to our initial example so each test runs only on its matching OS, and downstream jobs aren’t blocked by failures.
  • The two if checks skip non-matching OS steps, ensuring testing always passes.
  • continue-on-error: true on reports lets deploy run even if the upload step fails.

Watch Video