DEV Community

Harsh Pandhe
Harsh Pandhe

Posted on

GitHub Series: Day 4 – Automate Like a Boss with GitHub Actions πŸ€–βš™οΈ

Welcome back, developers! Yesterday, we learned how to branch and merge like Git ninjas. Today, we’re going full automation mode with GitHub Actions β€” your new best friend for building, testing, and deploying code without lifting a finger (well, almost 😎).


🧠 What are GitHub Actions?

Imagine having a robot that checks your code, runs tests, deploys apps, makes you coffee (okay, not that last one… yet) β€” all triggered by events like pushing to a branch or opening a pull request.
That’s GitHub Actions. It's a powerful CI/CD (Continuous Integration / Continuous Deployment) system built right into GitHub.

Github


πŸ”₯ Why Use GitHub Actions?

  • βœ… Automate repetitive tasks
  • πŸ§ͺ Run tests every time code is pushed
  • πŸš€ Deploy apps automatically
  • πŸ“¦ Build and publish packages
  • 🀝 Boost collaboration with teams

πŸ› οΈ Setting Up Your First GitHub Action

Here’s how to build a simple GitHub Action that runs tests when code is pushed:

1. Create a workflow file

Inside your repo, make this folder:

.github/workflows/
Enter fullscreen mode Exit fullscreen mode

Then create a file like ci.yml.

2. Add this starter config:

name: Run Python Tests

on: [push, pull_request]

jobs:
  test:
    runs-on: ubuntu-latest

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

      - name: Set up Python
        uses: actions/setup-python@v4
        with:
          python-version: '3.10'

      - name: Install dependencies
        run: pip install -r requirements.txt

      - name: Run tests
        run: pytest
Enter fullscreen mode Exit fullscreen mode

And boom β€” your tests will now run automatically whenever you push code!


🚦 Common Use Cases

Use Case Trigger Example
Linting on: push Auto-check code style (e.g., with ESLint or Black)
Deployment on: push to main Deploy app to Vercel, Heroku, Netlify, etc.
Notifications on: issues Send Slack or Discord alerts
Testing on: pull_request Run unit tests before merging

🧩 Pro Tip: Use Actions from the Marketplace

Why reinvent the wheel? Head over to GitHub Marketplace and use thousands of pre-built actions.

Examples:

  • actions/checkout β†’ Pulls repo code
  • actions/setup-node β†’ Sets up Node.js
  • docker/build-push-action β†’ Builds & pushes Docker images

Github

πŸ’‘ Best Practices

  • βœ… Keep workflows small and focused
  • πŸ” Use reusable workflows to avoid duplication
  • πŸ§ͺ Run tests before deploying
  • ⏱️ Don’t trigger workflows on every tiny change β€” be specific with paths and branches

πŸš€ Conclusion

GitHub Actions is your personal DevOps assistant. Whether you're solo-building a portfolio site or working in a team on a massive app, automation will save your time and sanity.

Tomorrow?

We’ll wrap this series with something close to every developer’s heart β€” Open Source Contributions πŸ’–
How to find cool projects, make meaningful PRs, and become a contributor!

Top comments (1)

Collapse
 
nevodavid profile image
Nevo David

pretty cool seeing automation getting this easy tbh - you reckon the hard part is setting it up or actually keeping all the jobs useful once the shine wears off?