Script Valley
CI/CD with GitHub Actions
GitHub Actions FundamentalsLesson 1.2

GitHub Actions YAML workflow file structure explained

YAML syntax, workflow file location, on trigger block, jobs block, runs-on key, steps array, name field

Workflow File Location

Workflow file location in repo

Every GitHub Actions workflow lives at .github/workflows/<filename>.yml in your repository. The filename can be anything — GitHub scans the entire directory.

Minimal Workflow Structure

Here is the smallest valid workflow that runs on every push:

name: CI Pipeline

on:
  push:
    branches: [main]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Check out code
        uses: actions/checkout@v4

      - name: Print message
        run: echo "Workflow executed successfully"

Breaking Down the Keys

name — optional display name shown in the GitHub UI. on — defines trigger events. Here, any push to main fires it. jobs — a map of one or more jobs. Each key (build) is the job ID. runs-on — the runner OS. ubuntu-latest is the most common choice. steps — ordered list of tasks. uses references a reusable Action; run executes a shell command.

YAML is indentation-sensitive. Two-space indentation is the convention. A misplaced space causes a parse error and the workflow will not run. Always validate your YAML before committing.

Up next

How GitHub Actions triggers and events work

Sign in to track progress