GitHub Actions, Instruction of Workflow Setup
GitHub Actions lets developers automate software workflows directly in their repositories. Learn how to write, configure, and optimize GitHub Actions for CI/CD, automation, and complex DevOps pipelines from scratch.

Written by Zisanur Haque
AI Product engineer writing about systems, growth, and the craft behind the code.
GitHub Actions is a powerful automation tool built into GitHub that allows you to define workflows to build, test, and deploy code whenever an event occurs in your repository. Think of it as a personal assistant for your repository that reacts automatically to pushes, pull requests, issues, or even custom triggers.
What Are GitHub Actions?
In simple terms, GitHub Actions are scripts that run in response to events inside a repository. They are YAML based workflows stored in the .github/workflows/ directory. Each workflow can have one or multiple jobs, and each job can have several steps.
Imagine your repository as a factory: whenever new code is pushed, GitHub Actions can automatically compile it, run tests, package it, and even deploy it, all without manual intervention.
Why Use GitHub Actions?
- Automate repetitive tasks like testing and deployment
- Integrate CI/CD pipelines directly in GitHub
- Run code quality checks before merging pull requests
- Deploy applications automatically to cloud services
- Trigger workflows from GitHub events or external APIs
GitHub Actions Structure
A GitHub Actions workflow has three main components:
1. Workflow
The YAML file that defines the automation. Stored in .github/workflows/.
2. Job
A workflow can have multiple jobs, each running on a specific runner (like Ubuntu, Windows, or macOS). Jobs run in parallel by default but can be configured to run sequentially.
3. Step
Steps are individual tasks within a job. Steps can run shell commands or use pre built actions from the GitHub Marketplace.
Basic Workflow Example
Here's a simple workflow that runs tests on every push:
name: CI
on: [push]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.11
- name: Install dependencies
run: pip install -r requirements.txt
- name: Run tests
run: pytest
Explanation:
- on: [push] triggers the workflow whenever code is pushed.
- uses: actions/checkout@v3 checks out your repository.
- Other steps install dependencies and run tests automatically.
Writing Custom Scripts in Workflows
You can execute any shell commands, Python scripts, or Node.js scripts as part of a workflow. Steps can include inline commands or call external scripts in your repository.
Example: Running a Deployment Script
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run deployment script
run: bash ./scripts/deploy.sh
Here, deploy.sh contains all the commands to build and deploy your app. This approach separates workflow logic from scripts, making maintenance easier.
Understanding Workflow Triggers
GitHub Actions can be triggered by a variety of events:
- push: Triggered when code is pushed.
- pull_request: Triggered for PR creation or updates.
- schedule: Triggered on cron schedules.
- workflow_dispatch: Manually trigger workflows from GitHub UI.
- repository_dispatch: Triggered via API call.
Advanced Workflow Techniques
1. Using Secrets
Keep sensitive information like API keys safe by storing them in GitHub Secrets:
run: |
echo ${{ secrets.MY_SECRET }}
2. Conditional Execution
Run steps only if conditions are met:
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
3. Matrix Builds
Test your code across multiple environments:
strategy:
matrix:
python-version: [3.9, 3.10, 3.11]
Best Practices
- Keep workflows modular by splitting multiple jobs.
- Use pre built actions from GitHub Marketplace when possible.
- Store reusable scripts in
scripts/instead of inline commands. - Monitor workflow run times and optimize steps to save compute minutes.
- Secure secrets and never hardcode credentials.
Real World Use Cases
- Continuous Integration: Test code automatically on every push.
- Continuous Deployment: Deploy apps to AWS, Azure, or Heroku.
- Automated Code Reviews: Run linters, formatters, and security checks.
- Scheduled Tasks: Cron jobs for database backups or report generation.
Conclusion
GitHub Actions transforms your repository into a fully automated workspace. With proper workflow design, scripting, and triggers, you can implement CI/CD, DevOps automation, and event-driven pipelines with minimal effort. Mastering Actions not only speeds up your development process but also ensures reliability and consistency across your projects.