Automate your workflow like a pro — no matter what tech stack you use.
GitHub Actions is a powerful CI/CD tool built right into GitHub. Whether you're working with Node.js, Python, Go, Java, Docker, or any other stack, you can automate your builds, tests, deployments, and more — all with simple YAML configurations.
In this guide, I’ll walk you through setting up GitHub Actions for any project, from scratch. Perfect for beginners and a refresher for pros.
🚀 Step 1: Create a .github/workflows
Directory
First, in the root of your project, create a directory called .github/workflows
.
mkdir -p .github/workflows
This is where all your GitHub Actions YAML files will live.
🛠️ Step 2: Add Your First Workflow File
Create a file like main.yml
inside the .github/workflows
directory:
# .github/workflows/main.yml
name: CI Pipeline
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Node.js (or your runtime)
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Install dependencies
run: npm install
- name: Run tests
run: npm test
💡 Tip: Replace the runtime and commands according to your project (Python, Go, Java, etc.).
📦 Step 3: Customize for Your Stack
Here’s how to tweak it depending on your language:
Python Example:
- uses: actions/setup-python@v4
with:
python-version: '3.11'
- run: pip install -r requirements.txt
- run: pytest
Go Example:
- uses: actions/setup-go@v4
with:
go-version: '1.21'
- run: go test ./...
Docker Example:
- name: Build Docker Image
run: docker build -t my-app .
🧩 Mix and match steps to suit multi-language or fullstack projects.
🧪 Step 4: Test the Workflow
Push your changes to GitHub. GitHub Actions will automatically trigger based on your config (e.g., push to main
).
Go to the Actions tab in your repo to view the workflow run. Check logs, outputs, and errors in real-time.
📤 Step 5: Deploy (Optional)
You can add deployment steps easily:
Deploy to GitHub Pages:
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public
Deploy to SSH Server:
- name: Deploy over SSH
uses: appleboy/scp-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.PRIVATE_KEY }}
source: "dist"
target: "/var/www/app"
🧠 Pro Tips
- Use secrets to store credentials (API keys, SSH keys, etc.).
- Split large workflows into multiple YAML files.
- Use
matrix
strategy to test against multiple versions/environments. - Schedule jobs with
on: schedule
for cron-like tasks.
✅ Final Thoughts
GitHub Actions helps you ship faster with less manual work. Start simple, iterate often, and explore the GitHub Marketplace for thousands of prebuilt actions.
If you found this useful, follow me on Dev.to and let's connect on GitHub. Happy automating! ⚙️✨
Top comments (2)
Well explained! I recently used it in my project to create a CI/CD pipeline. The simplicity of YAML, along with the comprehensive documentation, makes it an ideal tool for anyone looking to automate integration and deployment processes.
pretty cool seeing these setups broken down - i always mess something up the first try but once it clicks it just sticks