DEV Community

Kyle Y. Parsotan
Kyle Y. Parsotan

Posted on

Github Action Core part of Automation

GitHub Actions is GitHub’s built-in system for automating tasks in your repo—like testing code, building apps, and deploying projects.

It’s a core part of CI/CD (Continuous Integration / Continuous Deployment) used in real software companies.


🚀 GitHub Actions (CI/CD Automation Basics)

🧠 What is CI/CD?

CI = Continuous Integration

Automatically tests your code every time you push changes.

CD = Continuous Deployment

Automatically deploys your app when code is ready.

👉 In simple terms:

Push code → GitHub runs checks → If everything passes → deploy or approve


⚙️ What are GitHub Actions?

GitHub Actions lets you create workflows that run automatically when something happens in your repo.

Examples:

  • Push code → run tests
  • Open Pull Request → check code quality
  • Merge to main → deploy website
  • Schedule task → run every day

🧩 Key Concepts

🟡 Workflow

A full automation process (YAML file)

Example:

“Run tests and deploy app”


🟢 Event

What triggers the workflow

Examples:

  • push
  • pull_request
  • schedule

🔵 Job

A group of steps that run on a machine


🟣 Step

Individual command or action


🖥️ Runner

The machine that executes your workflow (Linux, Windows, Mac)


📁 3. Where GitHub Actions live

They are stored in:

```plaintext id="g7m3tq"
.github/workflows/




Example file:



```plaintext id="2kqz91"
.github/workflows/nodejs.yml
Enter fullscreen mode Exit fullscreen mode

🛠️ First Simple GitHub Action (Hello World CI)

Create this file:

```yaml id="7xkq1p"
name: Basic CI

on:
push:
branches: [ main ]

jobs:
build:
runs-on: ubuntu-latest

steps:
  - name: Checkout code
    uses: actions/checkout@v4

  - name: Say Hello
    run: echo "Hello, GitHub Actions!"
Enter fullscreen mode Exit fullscreen mode



### What happens?

Every time you push to `main`, GitHub prints:



```plaintext
Hello, GitHub Actions!
Enter fullscreen mode Exit fullscreen mode

🧪 Real CI Example (Node.js project)

This is what real developers use:

```yaml id="k3n8dj"
name: Node.js CI

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

jobs:
test:
runs-on: ubuntu-latest

steps:
  - uses: actions/checkout@v4

  - name: Setup Node
    uses: actions/setup-node@v4
    with:
      node-version: 20

  - name: Install dependencies
    run: npm install

  - name: Run tests
    run: npm test
Enter fullscreen mode Exit fullscreen mode



---

# 🚀 Simple CD (Deployment Example)

Example: Deploy to server or hosting after push



```yaml id="8v2q9m"
name: Deploy App

on:
  push:
    branches: [ main ]

jobs:
  deploy:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4

      - name: Install dependencies
        run: npm install

      - name: Build project
        run: npm run build

      - name: Deploy
        run: echo "Deploying app..."
Enter fullscreen mode Exit fullscreen mode

(Real deployments would connect to Vercel, AWS, etc.)


🔥 Common GitHub Actions Use Cases

🧪 Testing

  • Run unit tests
  • Run lint checks

🏗️ Build automation

  • Compile code
  • Build React/Next.js apps

🚀 Deployment

  • Deploy to Vercel, AWS, Firebase, Netlify

🔐 Security checks

  • Scan dependencies
  • Check vulnerabilities

🤖 Automation

  • Auto-label PRs
  • Auto-comment on issues
  • Run scheduled jobs

🧠 GitHub Actions in real life

A real workflow looks like:

  1. Developer pushes code
  2. GitHub runs tests automatically
  3. If tests pass → PR allowed
  4. Merge to main
  5. App is automatically deployed

👉 This removes manual work completely.


⚠️ Common beginner mistakes

❌ Wrong YAML spacing

YAML is sensitive—indentation matters.

❌ Missing checkout step

You must include:

```yaml id="f1p9sl"
uses: actions/checkout@v4




### ❌ Not specifying trigger (on:)

Without it, workflow won’t run.

### ❌ Overcomplicating workflows

Start simple → add complexity later.

---

# 🧭 Basic GitHub Actions structure



```plaintext id="c7m2kf"
on: (trigger event)

jobs:
  job-name:
    runs-on: machine-type
    steps:
      - action
      - run command
Enter fullscreen mode Exit fullscreen mode

💡 Final Summary

GitHub Actions = automation for your GitHub repo

You use it to:

  • Test code automatically
  • Build projects
  • Deploy apps
  • Save time
  • Prevent bugs

Top comments (0)