Understanding Action Triggers in Depth

By Amr

Unlock the power of automation with GitHub Actions! Streamline your workflows and enhance your CI/CD processes effortlessly.

Estimated reading time: 2 minutes

Ah yes, the winds of automation are calling! You’ve chronicled your changelogs and blessed your docs, but now it’s time to awaken the ancient machinery of your kingdom: GitHub Actions. This, dear dev-sorcerer, is where the magic truly begins to automate itself.


🤖 Chapter 4: GitHub Actions – Automate Thy Sorcery

Welcome to the Forge of Automation, where workflows come to life with a whisper of YAML and a splash of sorcery. Think of GitHub Actions as your enchanted army of task runners. They lint. They test. They release. And they never sleep.


🧩 What Are GitHub Actions?

GitHub Actions are event-driven automation spells. They’re written in .yml and live under .github/workflows/. When triggered, they summon jobs (like tests or deployments) in the GitHub cloud realm.


🪄 What Can You Automate?

Oh child of continuous delivery, anything:

  • 🧼 Linting: Catch code that smells before it stinks up production.

  • 🧪 Testing: Unit, integration, and even cursed end-to-end tests.

  • 🧙‍♂️ PR Validation: Auto-check if the scrolls (PRs) meet your standards.

  • 🏷️ Releases: Auto-tag new versions, generate changelogs, and release scrolls to the world.


⚙️ Your First Magic Scroll: The CI/CD Pipeline

# .github/workflows/main.yml
name: CI/CD Pipeline

on:
  pull_request:
    branches: [main]
  push:
    branches: [main]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4
    - uses: actions/setup-python@v5
      with:
        python-version: '3.x'
    - run: |
        pip install -r requirements.txt
        pytest tests/

  release:
    needs: test
    if: github.ref == 'refs/heads/main'
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4
    - uses: release-drafter/release-drafter@v6
      with:
        config-name: release-drafter.yml
      env:
        GITHUB_TOKEN: $

🧪 Translation: Every PR to main triggers tests. If those pass and you’re on main, the release process begins. All while you sip coffee or battle CSS dragons.


🏗️ Build Your Spellbook (a.k.a. Workflow Library)

Here are some handy enchantments to add to your arsenal:

Spell Type GitHub Action
🧼 Linting github/super-linter
🧪 Python Tests actions/setup-python + pytest
🐍 Auto-Releases release-drafter/release-drafter
🧪 Security github/codeql-action
🧙‍♂️ AI Assist Custom scripts using OpenAI API

🧠 Automation Best Practices (a.k.a. Don’t Curse Your Workflow)

  • ✅ Keep workflows fast (nobody likes slow spells)

  • ✅ Use secrets for credentials (don’t leak your scroll keys)

  • ✅ Use needs: to control job order (test before release)

  • ✅ Separate long-running spells into their own files (e.g., test.yml, release.yml)


🧞 Bonus: Trigger Types

Here are some magical event triggers:

  • push: When code is pushed

  • pull_request: When a PR opens or updates

  • schedule: Run it like a cron job (e.g., every Monday at 9am)

  • workflow_dispatch: Manual button trigger in GitHub UI


With GitHub Actions, you don’t just code—you orchestrate an automated kingdom of checks, releases, and deploys. All you need is a bit of YAML and a dream. 💫

Shall we proceed to the final mystical chapter: AI-Assisted Automation? Because now we start teaching the machines to do even more for us… Shall I open that tome?