DevOps Bootcamp · Lesson

Run Playbooks in GitHub Actions

Trigger automation from commits.

Lesson 2 of 413 steps

Run Playbooks in GitHub Actions is a free DevOps Bootcamp lesson on CoddyKit. This is lesson 2 of 4. Any 3 lessons of this learning path are free to read in full — after that, CoddyKit PRO unlocks every lesson, plus hands-on practice with a built-in code editor and a 24/7 AI tutor. It is part of the DevOps Bootcamp learning path, and your progress syncs across the web and the CoddyKit app. The DevOps Bootcamp course includes 4 lessons in total.

CI Runs Your Automation

With GitHub Actions, every push can run your playbooks on a fresh runner, so automation is tested the same way every time. 🚀

Workflows Live in .github

A workflow is a YAML file under .github/workflows; GitHub finds it there and runs it automatically.

.github/workflows/ansible.yml

Trigger on Push

The on key decides when a workflow runs. Triggering on push to main is the classic CI starting point.

on:
  push:
    branches: [ main ]

A Job on a Runner

Each job runs on a virtual machine you pick with runs-on, most often a clean ubuntu-latest image.

jobs:
  deploy:
    runs-on: ubuntu-latest

Check Out Your Code

The first step is almost always actions/checkout, which copies your repo onto the runner so playbooks are present.

- uses: actions/checkout@v4

Install Ansible on the Runner

The runner is bare, so add a step to install Ansible with pip before you can call any playbook.

- run: pip install ansible

Lint Before You Run

Add an ansible-lint step early; if it fails, the job stops and the deploy step never even starts.

- run: |
    pip install ansible-lint
    ansible-lint

Call ansible-playbook

The payoff step runs ansible-playbook just like your terminal would, pointing at your inventory and file.

- run: ansible-playbook -i inventory site.yml

Secrets, Not Hardcoded Keys

Never paste credentials in the YAML. Read them from GitHub Secrets through the secrets context instead.

env:
  SSH_KEY: ${{ secrets.SSH_KEY }}

Reach Hosts Over SSH

To touch real servers the runner needs the SSH key loaded into its agent, fed in from a secret you stored earlier.

Read the Live Logs

The Actions tab streams every step's output, so a failed task shows up exactly where Ansible reported it.

Quick Check

Where does a GitHub Actions workflow file belong?

Recap: Pushes Now Deploy

You built a workflow: trigger on push, check out, install Ansible, lint, then run the playbook with secrets. CI does the work now. 🎉

Free to start

Learn DevOps Bootcamp with an AI tutor — free

Write and run real code in your browser, get instant help from a 24/7 AI tutor, and pick up where you left off on the web or in the app.

Courses
142
Lessons
568

Frequently Asked Questions

Is the “Run Playbooks in GitHub Actions” lesson free?

Yes — any 3 lessons of the DevOps Bootcamp learning path, including “Run Playbooks in GitHub Actions”, are free to read in full here on the web. After that, CoddyKit PRO unlocks every lesson, plus interactive practice with a built-in code editor and a 24/7 AI tutor. The DevOps Bootcamp course includes 4 lessons in total.

What will I learn in “Run Playbooks in GitHub Actions”?

Trigger automation from commits. You practise DevOps Bootcamp with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start DevOps Bootcamp?

No prior experience is required. DevOps Bootcamp on CoddyKit is structured for beginners through advanced learners, so you can start here or from the beginning and move at your own pace. This is lesson 2 of 4.

How long does the “Run Playbooks in GitHub Actions” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this DevOps Bootcamp lesson?

Yes. Every DevOps Bootcamp lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. ansible-lint as a Quality Gate
  2. Run Playbooks in GitHub Actions
  3. Vault Secrets in a Pipeline
  4. Gated Deploys with Approvals & Check Mode
← Back to DevOps Bootcamp