1. Workflow syntax encyclopedia
Encyclopedia home · Platform comparison · Catalog
Start with a complete example from T01 or T02. Work from the outside in. Read the event first, trace the job dependencies, then inspect steps and their inputs.
1.1 Workflow keys
| Key | Accepted shape and purpose | Expected evidence and common mistake |
|---|---|---|
name | String displayed as the workflow name | Check the list of workflows. name does not select which branch triggers a run. |
run-name | String or supported expression describing one execution | A manual run can include its input in the list title. Inspect the run title, not a job label. |
on | Event string, list or event mapping | Push, PR and dispatch are distinct events. A PR branch filter selects the target branch. Quote glob strings. |
permissions | Permission map or platform-supported aggregate value | Access remains limited by the caller context. Bogus or overbroad scopes are a separate issue from secret availability. |
env | String values exported to steps | A job or step may override a same-named workflow variable. Define secrets through the platform's secret context. |
defaults | run.shell and run.working-directory | Commands use requested shell and directory. Action steps have their own behavior. |
concurrency | Group string or mapping with group and cancel-in-progress | Trigger overlapping disposable runs and inspect pending/cancelled states. Grouping is not a guaranteed FIFO queue. |
jobs | Mapping of job IDs to job objects | The job graph uses IDs. Display names can differ. |
1.2 Job keys
| Key | Accepted shape and purpose | Expected evidence and common mistake |
|---|---|---|
runs-on | Runner label, label list or supported group/label object | Check the registered executor. A label is selection metadata and does not install a toolchain. |
needs | Job ID or list of IDs | Dependencies govern order and outputs. Files require an artifact, registry or explicitly shared storage. |
if | Boolean expression | Job-level evaluation precedes matrix expansion on GitHub. Put matrix-dependent guards on a step or filter entries in the matrix. |
strategy | Mapping for matrix, fail-fast and max-parallel | Inspect generated jobs and bounded parallelism separately. |
strategy.matrix | Dimension arrays and optional include/exclude or expression | Quote version numbers so YAML retains intended strings. Test filtered combinations. |
container | Image string or container configuration object | Step commands run inside the chosen image on a supported Linux runner. Verify which shell and tools exist. |
services | Map of service IDs to container definitions | Jobs running in their own container use service DNS names. Host jobs commonly use mapped ports. |
environment | Environment name or name/URL object | Approvals are actual repository protection settings on GitHub. Gitea currently documents this job field as ignored. |
outputs | Map from output names to producer step expressions | Read the value through needs and validate that it is initialized. |
timeout-minutes | Positive number within platform limits | The job stops near that boundary. Use shorter command and request deadlines as well. |
continue-on-error | Boolean or compatible expression | Limit it to deliberate experimental coverage. Set branch protection separately. |
uses | Reusable workflow path/reference | Job-level uses calls a workflow. A job with uses does not also define steps. |
with | Mapping of caller inputs | Match the declared workflow_call types. Quote values when they belong to string inputs. |
secrets | Explicit map, or supported inheritance form | Forward only required values. Verify scope and avoid passing secrets to untrusted reusable workflows. |
1.3 Step keys
| Key | Accepted shape and purpose | Expected evidence and common mistake |
|---|---|---|
name | Descriptive string | Shows in logs. It cannot be referenced as a step ID. |
id | Identifier valid within the job | Later steps can read steps.<id>.outputs. Use unique IDs. |
uses | Action reference, local action path or supported container URI | Check the action runtime and runner protocol. Checkout first for local actions. |
run | Shell command or multiline scalar | Exit status gates the next step. Prefer a literal block for commands containing colons. |
shell | Shell name or command template | Supply a compatible shell on the runner and verify error/pipe semantics. |
working-directory | Existing directory for a command | Applied to run steps. The directory typically appears after checkout. |
env | Environment mapping | Put untrusted context strings here and quote them in the shell. |
with | Action inputs mapping | Check declared action keys and expected types. It belongs with uses. |
if | Boolean expression | Check status functions if a cleanup or report step needs to run after failure. |
continue-on-error | Boolean or expression | Compare the step's raw outcome and final conclusion when collecting evidence. |
timeout-minutes | Positive number within platform limits | A blocked command reaches a bounded stop, separate from a job's deadline. |
1.4 Expression function reference
The examples below use GitHub Actions contexts. Gitea currently documents support for standard expression functions, and the actual server, runner and action versions still control context and feature behavior. Try the workflow on the exact pair you use. hashFiles() operates on the job workspace, so it belongs after checkout in a step-capable context.
| Function | Values and scope | Result in the fixture |
|---|---|---|
success() | No arguments. Status guard in job or step conditions. | Pass mode prints success. Fail mode skips it. |
failure() | No arguments. Status guard can see earlier failure. | Fail mode prints failure and the run remains failed. |
always() | No arguments. True even after failure or cancellation evaluation. | The simple report guard runs on success or failure. Use only bounded, safe steps. |
cancelled() | No arguments. Status guard checks cancellation. | Cancel the wait mode while the test step is running and inspect the cancellation step. The runner can be interrupted before it can emit logs. |
contains() | String search or element membership in an array. Case-insensitive string comparisons. | Checking a JSON-parsed list for linux returns true. |
startsWith() | String and prefix. Case-insensitive. | release-v1 with prefix release- returns true. |
endsWith() | String and suffix. Case-insensitive. | report.xml with suffix .xml returns true. |
format() | Format string and indexed replacement arguments. Escape literal braces by doubling. | 'ci-{0}' with 'lab' becomes ci-lab. |
join() | Array or string plus optional separator. | JSON list of build and test becomes build/test. |
toJSON() | Supported context value, object or scalar. | The matrix example emits JSON text. Avoid serializing secrets or complete sensitive contexts into logs. |
fromJSON() | Valid JSON string representing an object, array or typed scalar. | '3' becomes a number. Invalid JSON fails evaluation before shell execution. |
hashFiles() | Workspace-relative glob patterns. Returns an empty string on no matches. | An existing README produces a nonempty hash after checkout. |
Save this complete fixture as .github/workflows/expression-lab.yml. Run pass, fail, then wait mode. On Gitea use .gitea/workflows/, confirm manual input support, and change action or label only after checking the installed version. The workflow has no deployment or state-changing privileges.
name: Expression lab
on:
workflow_dispatch:
inputs:
mode:
description: Pass, fail, or leave time for manual cancellation
type: choice
options: [pass, fail, wait]
default: pass
permissions:
contents: read
jobs:
expressions:
runs-on: ubuntu-latest
timeout-minutes: 3
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Check pure expressions
env:
PRESENT: ${{ contains(fromJSON('["linux","macos"]'), 'linux') }}
PREFIX: ${{ startsWith('release-v1', 'release-') }}
SUFFIX: ${{ endsWith('report.xml', '.xml') }}
LABEL: ${{ format('ci-{0}', 'lab') }}
PATH_TEXT: ${{ join(fromJSON('["build","test"]'), '/') }}
JSON_TEXT: ${{ toJSON(fromJSON('{"runtime":"3.12"}')) }}
COUNT: ${{ fromJSON('3') }}
SOURCE_HASH: ${{ hashFiles('README.md') }}
run: |
test "$PRESENT" = true
test "$PREFIX" = true
test "$SUFFIX" = true
test "$LABEL" = ci-lab
test "$PATH_TEXT" = build/test
test "$COUNT" -eq 3
test -n "$SOURCE_HASH"
printf '%s\n' "$JSON_TEXT"
- name: Intentional outcome
env:
MODE: ${{ inputs.mode }}
run: |
case "$MODE" in
pass) echo 'pass fixture' ;;
fail) exit 1 ;;
wait) sleep 90 ;;
*) exit 2 ;;
esac
- name: Observe success
if: success()
run: echo success
- name: Observe failure
if: failure()
run: echo failure
- name: Observe final state
if: always()
run: echo report
- name: Observe cancellation when scheduled
if: cancelled()
run: echo cancelled