Part 2: YAML Syntax and Workflow Fundamentals
Introduction
YAML Basics for GitHub Actions
What is YAML?
Basic YAML Syntax
# This is a comment
# String (no quotes needed)
name: CI Pipeline
# String with quotes (needed for special characters)
message: "Hello, World!"
# Number
timeout: 30
# Boolean
enabled: true
disabled: false
# List (array)
branches:
- main
- develop
- staging
# Alternative list syntax
branches: [main, develop, staging]
# Object (dictionary/map)
environment:
name: production
url: https://api.example.com
# Nested structures
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3Complete Workflow Structure
Workflow Triggers (on)
on)Push Events
Pull Request Events
Release Events
Scheduled Events (Cron)
Manual Workflow Dispatch
Multiple Triggers
Jobs Configuration
Basic Job
Job Dependencies
Conditional Jobs
Job Outputs
Steps Configuration
Using Actions
Running Commands
Environment Variables in Steps
Conditional Steps
Environment Variables and Secrets
Workflow-Level Environment Variables
Job-Level Environment Variables
Using Secrets
Default Environment Variables
Context and Expressions
Using Contexts
Expressions and Functions
Status Check Functions
Service Containers
Matrix Strategy
Complete Real-World Example
Key Takeaways
PreviousPart 1: Introduction to GitHub Actions and First WorkflowNextPart 3: Building CI/CD Pipelines for TypeScript Microservices
Last updated