Skip to content

1. Workflow fundamentals ​

Home · Full index

Use these examples to see what triggers a workflow, how jobs depend on one another, and where values live. Actions examples assume Bash on Linux and a repository whose default branch is main. GitHub workflows go under .github/workflows/. Gitea workflows go under .gitea/workflows/.

1.1 F01 · First workflow ​

GitHub Actions and Gitea · Full workflow. Save as hello.yml in the platform directory. On Gitea, confirm that a registered runner advertises ubuntu-latest.

yaml
name: Hello CI
on: [push]
jobs:
  hello:
    runs-on: ubuntu-latest
    steps:
      - run: printf 'CI is running on %s\n' "$(uname -s)"

Verify. Push a commit and open the hello job log. Look for CI is running on Linux.

1.2 F02 · Branches, paths and manual dispatch ​

GitHub Actions · Trigger block. Replace the existing on block. Keep a separate, always-running workflow for a required check if an event-level path filter can skip runs.

yaml
on:
  push:
    branches: [main]
    paths:
      - 'src/**'
      - 'tests/**'
      - 'pyproject.toml'
      - 'uv.lock'
      - '.github/workflows/ci.yml'
  pull_request:
    branches: [main]
  workflow_dispatch:

Verify. A push to main that changes only README.md should skip this workflow. A PR targeting main should run it. Manual dispatch requires this workflow to exist on the default branch.

1.3 F03 · Parallel jobs and a dependency gate ​

GitHub Actions and Gitea · Full workflow. Independent jobs are eligible to run concurrently. Actual overlap depends on runner capacity.

yaml
name: Dependency graph
on: [push]
jobs:
  lint:
    runs-on: ubuntu-latest
    steps:
      - run: echo "Lint passed"
  test:
    runs-on: ubuntu-latest
    steps:
      - run: echo "Tests passed"
  package:
    needs: [lint, test]
    runs-on: ubuntu-latest
    steps:
      - run: echo "Packaging may start"

Verify. On a scratch branch change the lint command to exit 1. Look for a failed lint job, a finished test job and a skipped package job. Restore the lint command afterward.

1.4 F04 · Step, job and workflow variables ​

GitHub Actions and Gitea · Full workflow. Use env for plain environment values. Use a platform secret store for sensitive values.

yaml
name: Variable scope
on: [push]
env:
  APP_NAME: calculator

jobs:
  show:
    runs-on: ubuntu-latest
    env:
      APP_MODE: test
    steps:
      - name: Print the three scopes
        env:
          APP_DETAIL: smoke
        run: printf '%s %s %s\n' "$APP_NAME" "$APP_MODE" "$APP_DETAIL"
      - name: Check step scope
        run: test -z "${APP_DETAIL:-}"

Verify. The first step prints calculator test smoke. The second step succeeds because the first step's APP_DETAIL setting is scoped to that step.

1.5 F05 · Write a value for a later step ​

GitHub Actions and Gitea · Steps fragment. Paste under one job's steps. A value written to GITHUB_ENV is available to subsequent steps in that job.

yaml
- name: Record build mode
  run: printf 'BUILD_MODE=debug\n' >> "$GITHUB_ENV"
- name: Consume build mode
  run: test "$BUILD_MODE" = debug

Verify. Move the assertion before the write on a scratch branch, then compare the two runs.

1.6 F06 · Pass a job output ​

GitHub Actions · Full workflow. Use an artifact for files and a job output for a small value.

yaml
name: Job outputs
on: [push]
permissions:
  contents: read
jobs:
  metadata:
    runs-on: ubuntu-latest
    outputs:
      commit: ${{ steps.identity.outputs.commit }}
    steps:
      - id: identity
        run: printf 'commit=%s\n' "$GITHUB_SHA" >> "$GITHUB_OUTPUT"
  show:
    needs: metadata
    runs-on: ubuntu-latest
    steps:
      - env:
          BUILT_COMMIT: ${{ needs.metadata.outputs.commit }}
        run: test "$BUILT_COMMIT" = "$GITHUB_SHA"

Verify. The second job succeeds even though it does not check out files or use a shared filesystem.

1.7 F07 · Typed manual input ​

GitHub Actions · Full workflow. Put this on the default branch first. The two targets here only change a log message.

yaml
name: Manual smoke mode
on:
  workflow_dispatch:
    inputs:
      mode:
        description: Smoke test mode
        type: choice
        options: [quick, thorough]
        default: quick
      verbose:
        description: Print extra detail
        type: boolean
        default: false
permissions: {}
jobs:
  run:
    runs-on: ubuntu-latest
    steps:
      - env:
          MODE: ${{ inputs.mode }}
        run: printf 'Mode is %s\n' "$MODE"
      - if: inputs.verbose
        run: echo "Verbose output enabled"

Verify. Dispatch once with the checkbox clear and once selected. Compare the visibility of the last step.

1.8 F08 · Cancel superseded PR runs ​

GitHub Actions · Top-level fragment. Pair with on: [pull_request].

yaml
concurrency:
  group: ${{ github.workflow }}-pr-${{ github.event.pull_request.number }}
  cancel-in-progress: true

Verify. Push two commits to the same PR while the first run is still working. Look for the first run to be cancelled. For serialized release jobs, use a deployment-specific group and read D03.

Reference · GitHub workflow syntax, workflow commands, Gitea Actions comparison.