How to Set Up a CI/CD Pipeline with GitHub Actions
GitHub Actions is a powerful automation engine built into GitHub. It allows you to build, test, and deploy your applications directly from your repository without maintaining separate CI servers.
In this tutorial, you’ll create a robust pipeline that runs automated tests on every commit and deploys to a server after successful verification. Basic YAML knowledge is helpful.

1. Create the Workflow File
In your repository, create a folder named .github/workflows. Add a YAML file, for example ci-cd.yml, to define the pipeline configuration.
2. Define Triggers and Build Job
- Use the on directive to trigger the pipeline on push or pull_request events.
- Set runs-on: ubuntu-latest as the virtual environment.
- Add steps to checkout code, install dependencies, and run tests like npm test.
3. Add a Deployment Job
Create a second job that depends on the test job using needs. Use GitHub Secrets to store your server IP, username, and SSH key. Then deploy using a community action or a simple SSH command.
4. Apply Best Practices
- Cache dependencies to speed up builds.
- Pin actions to specific commit SHAs for supply-chain security.
- Require manual approval for production deployment via environment protection rules.
Conclusion
You now have a fully automated CI/CD pipeline. Every push triggers tests, and a successful run automatically deploys your application, giving you faster, more reliable releases.