A Beginner’s Guide to Setting Up Your First CI/CD Pipeline

In our last post, we talked about why Continuous Integration and Continuous Deployment (CI/CD) is the backbone of a modern DevOps workflow. Today, we are going to stop talking theory and start building.
If you are a freelancer or a small team, you don't need complex tools like Jenkins or Spinnaker. You can set up a powerful, free pipeline right inside your GitHub repository using GitHub Actions.
Here is a step-by-step guide to creating a pipeline that automatically tests your code and deploys it whenever you push to your `main` branch.
Step 1: Understand the Workflow
A CI/CD pipeline is just a set of instructions. We are going to tell GitHub to do the following steps every time we save code:
- Trigger: Notice a push to the `main` branch.
- Build: Spin up a temporary server and install our dependencies (e.g., `npm install`).
- Test: Run our automated tests.
- Deploy: If tests pass, connect to your server via SSH and update the live site.
Step 2: Create the Workflow File
In your project repository, create a directory called .github/workflows. Inside that folder, create a file named deploy.yml.
Here is a basic template you can use (this example assumes a Node.js project, but the logic applies everywhere):
name: Production Deploy
on:
push:
branches: [ "main" ]
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Install Dependencies & Test
run: |
npm install
npm test
- name: Deploy via SSH
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SERVER_IP }}
username: ${{ secrets.SERVER_USER }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
script: |
cd /var/www/my-app
git pull origin main
npm install
pm2 restart all
Step 3: protecting Your Secrets
You noticed the ${{ secrets.SERVER_IP }} variables above, right? Never hardcode your server passwords or IP addresses into your code files.
Instead, go to your GitHub Repository Settings > Secrets and variables > Actions, and add your server details there. GitHub will inject them securely when the pipeline runs.
Step 4: Push and Watch
Commit your new file and push it to GitHub. Click the "Actions" tab in your repository, and you will see your pipeline running. If it turns green, congratulations! You just automated your deployment.
Is Your Environment Ready for Automation?
While the YAML file above looks simple, the tricky part is usually the server side: generating SSH keys, configuring permissions, and ensuring your server environment matches your testing environment.
If you are struggling with "Permission Denied" errors, SSH handshakes, or failed builds, PraxisServe can help.
We configure robust CI/CD pipelines for freelancers and teams so you can deploy with confidence, every single time.
Need Help with This?
Our team is ready to assist you with implementation and support.