Skip to content

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 ​

KeyAccepted shape and purposeExpected evidence and common mistake
nameString displayed as the workflow nameCheck the list of workflows. name does not select which branch triggers a run.
run-nameString or supported expression describing one executionA manual run can include its input in the list title. Inspect the run title, not a job label.
onEvent string, list or event mappingPush, PR and dispatch are distinct events. A PR branch filter selects the target branch. Quote glob strings.
permissionsPermission map or platform-supported aggregate valueAccess remains limited by the caller context. Bogus or overbroad scopes are a separate issue from secret availability.
envString values exported to stepsA job or step may override a same-named workflow variable. Define secrets through the platform's secret context.
defaultsrun.shell and run.working-directoryCommands use requested shell and directory. Action steps have their own behavior.
concurrencyGroup string or mapping with group and cancel-in-progressTrigger overlapping disposable runs and inspect pending/cancelled states. Grouping is not a guaranteed FIFO queue.
jobsMapping of job IDs to job objectsThe job graph uses IDs. Display names can differ.

1.2 Job keys ​

KeyAccepted shape and purposeExpected evidence and common mistake
runs-onRunner label, label list or supported group/label objectCheck the registered executor. A label is selection metadata and does not install a toolchain.
needsJob ID or list of IDsDependencies govern order and outputs. Files require an artifact, registry or explicitly shared storage.
ifBoolean expressionJob-level evaluation precedes matrix expansion on GitHub. Put matrix-dependent guards on a step or filter entries in the matrix.
strategyMapping for matrix, fail-fast and max-parallelInspect generated jobs and bounded parallelism separately.
strategy.matrixDimension arrays and optional include/exclude or expressionQuote version numbers so YAML retains intended strings. Test filtered combinations.
containerImage string or container configuration objectStep commands run inside the chosen image on a supported Linux runner. Verify which shell and tools exist.
servicesMap of service IDs to container definitionsJobs running in their own container use service DNS names. Host jobs commonly use mapped ports.
environmentEnvironment name or name/URL objectApprovals are actual repository protection settings on GitHub. Gitea currently documents this job field as ignored.
outputsMap from output names to producer step expressionsRead the value through needs and validate that it is initialized.
timeout-minutesPositive number within platform limitsThe job stops near that boundary. Use shorter command and request deadlines as well.
continue-on-errorBoolean or compatible expressionLimit it to deliberate experimental coverage. Set branch protection separately.
usesReusable workflow path/referenceJob-level uses calls a workflow. A job with uses does not also define steps.
withMapping of caller inputsMatch the declared workflow_call types. Quote values when they belong to string inputs.
secretsExplicit map, or supported inheritance formForward only required values. Verify scope and avoid passing secrets to untrusted reusable workflows.

1.3 Step keys ​

KeyAccepted shape and purposeExpected evidence and common mistake
nameDescriptive stringShows in logs. It cannot be referenced as a step ID.
idIdentifier valid within the jobLater steps can read steps.<id>.outputs. Use unique IDs.
usesAction reference, local action path or supported container URICheck the action runtime and runner protocol. Checkout first for local actions.
runShell command or multiline scalarExit status gates the next step. Prefer a literal block for commands containing colons.
shellShell name or command templateSupply a compatible shell on the runner and verify error/pipe semantics.
working-directoryExisting directory for a commandApplied to run steps. The directory typically appears after checkout.
envEnvironment mappingPut untrusted context strings here and quote them in the shell.
withAction inputs mappingCheck declared action keys and expected types. It belongs with uses.
ifBoolean expressionCheck status functions if a cleanup or report step needs to run after failure.
continue-on-errorBoolean or expressionCompare the step's raw outcome and final conclusion when collecting evidence.
timeout-minutesPositive number within platform limitsA 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.

FunctionValues and scopeResult 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.

yaml
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

1.5 References ​