Master GitHub Workflow YAML Tutorial: Build CI/CD Pipelines Fast

Logan Jul 13, 2026

Embarking on your GitHub Actions journey? A powerful tool for automating your software workflow, GitHub Actions is even more accessible with your own, custom workflows defined in YAML. Let's delve into crafting and managing your GitHub workflows using YAML.

Git Workflow
Git Workflow

Understanding the basics is key. YAML, or 'YAML Ain't Markup Language', is a human-readable data-serialization standard, ideal for ensuring your workflow files are both readable and easy to write. It's whitespace-indented, making it a great fit for describing complex configurations like your GitHub Actions workflows.

Git & GitHub Cheat Sheet πŸ”₯ | Commands, Workflow, Branching & Version Control (Beginner to Pro)
Git & GitHub Cheat Sheet πŸ”₯ | Commands, Workflow, Branching & Version Control (Beginner to Pro)

Defining Your Workflow

A GitHub Actions workflow consists of one or more jobs, defined within `jobs` key in your YAML file. Jobs run in parallel by default, unless you specify dependencies.

Git workflow with example
Git workflow with example

At the heart of your workflow lies the `on` key, triggering your workflow based on a specific event. This could be a push, pull request, or even a schedule. For instance, you might trigger a deployment workflow on a push event to your main branch:

```yaml on: push: branches: [ main ] ```

Understanding Jobs and Steps

π’π­πšπ πžπ¬ 𝐨𝐟 𝐆𝐒𝐭/π–π¨π«π€πŸπ₯𝐨𝐰
π’π­πšπ πžπ¬ 𝐨𝐟 𝐆𝐒𝐭/π–π¨π«π€πŸπ₯𝐨𝐰

Each job within your workflow consists of one or more steps, defined within the `jobs` key. Steps execute in sequential order, calling GitHub-hosted runners or your own runner if you've configured one. Here's an outline of a simple job:

```yaml jobs: build-and-deploy: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: Build run: npm ci && npm run build - name: Deploy run: | echo "Deploying..." ```

In this example, we're checking out the code, then executing two 'run' commands - the second with a multiline string - to build and deploy our application.

Environment Variables and Secrets

GitHub Complete Beginner Guide (2026) | Learn Git & GitHub Step-by-Step
GitHub Complete Beginner Guide (2026) | Learn Git & GitHub Step-by-Step

Environment variables and secrets can be defined within jobs to pass sensitive data. Environment variables are public and can be accessed in all steps of a job. Secrets, however, are encrypted and can only be used in specific steps:

```yaml jobs: my-job: runs-on: ubuntu-latest env: ENV_VAR: some-value steps: - uses: actions/checkout@v2 - name: Use env var run: echo " ENV_VAR is ${ENV_VAR}" - name: Use secret run: echo "SECRET is ${{ secrets.SECRET }}" env: SECRET: ${{ secrets.MY_SECRET }} ```

Deploying with Environments and Secrets

When deploying, you'll often want to manage different environments. This involves deploying to development, staging, and production. You can achieve this using context and environment variables in your YAML:

Git & GitHub Cheat Sheet Every Developer Needs
Git & GitHub Cheat Sheet Every Developer Needs

Start by defining your environments in your repo:

- In your GitHub repo, go to Settings. - Click on "Secrets". - Add new repositories secrets for each environment (like `_secondsess_secret` for production).

In your YAML, use ${{ secrets.SECOND_SECRET }} to access these secret values based on the environment you're deploying to:

Beginner’s Guide to Getting Started with GitHub in 2025 – Easy Step-by-Step Tutorial
Beginner’s Guide to Getting Started with GitHub in 2025 – Easy Step-by-Step Tutorial
LetsDevOps: GitHub Actions Tutorial for Beginner's
LetsDevOps: GitHub Actions Tutorial for Beginner's
Git Workflow Roadmap
Git Workflow Roadmap
a diagram showing how to use the flow tool for creating an interactive visual map in japanese
a diagram showing how to use the flow tool for creating an interactive visual map in japanese
Git & GitHub Explained for Beginners (2026)
Git & GitHub Explained for Beginners (2026)
GITHUB PROJECTS THAT CAN GET YOU HIRED
GITHUB PROJECTS THAT CAN GET YOU HIRED
the git workflow diagram is shown
the git workflow diagram is shown
Beginner Git Workflow Explained: Learn Git & GitHub Step-by-Step
Beginner Git Workflow Explained: Learn Git & GitHub Step-by-Step
Git & GitHub Roadmap for Beginners
Git & GitHub Roadmap for Beginners
Top 10  Free Courses to Learn Git and GitHub in 2025 (Udemy)
Top 10 Free Courses to Learn Git and GitHub in 2025 (Udemy)
Nikki Siapno on LinkedIn: GitHub Actions β€” How do you optimize their performance? GitHub Actions is…
Nikki Siapno on LinkedIn: GitHub Actions β€” How do you optimize their performance? GitHub Actions is…
Git vs. GitHub: A Beginner's Guide to Version Control & Collaboration πŸ‘©β€πŸ’»
Git vs. GitHub: A Beginner's Guide to Version Control & Collaboration πŸ‘©β€πŸ’»
Git Workflow
Git Workflow
πŸš€ Git & GitHub Project Setup: A Complete Overview
πŸš€ Git & GitHub Project Setup: A Complete Overview
the git workflow diagram is shown
the git workflow diagram is shown
Level Up Your Portfolio with These Beginner-Friendly GitHub Projects
Level Up Your Portfolio with These Beginner-Friendly GitHub Projects
TOP GITHUB PROJECT IDEAS FOR BEGINNERS
TOP GITHUB PROJECT IDEAS FOR BEGINNERS
a diagram showing the different stages of an object in which one is connected to another
a diagram showing the different stages of an object in which one is connected to another
git commit Explained (Day 6 Git Guide)
git commit Explained (Day 6 Git Guide)
the github chat sheet is displayed in this screenshote screen graber
the github chat sheet is displayed in this screenshote screen graber

```yaml jobs: deploy: runs-on: ubuntu-latest environment: name: ${{ matrix.environment }} url: https://${{ matrix.environment }}.myapp.com strategy: matrix: environment: [dev, staging, prod] steps: # checkout code... - name: Build run: npm run build - name: Deploy run: | echo "Deploying to ${{ matrix.environment }} environment..." echo "Source ${{ secrets.SECOND_SECRET }}" ```