Building a CI/CD pipeline with GitHub Actions
Step-by-step guide to automating your deployments with GitHub Actions and Shipyard for seamless continuous delivery.
Continuous Integration and Continuous Deployment (CI/CD) is the backbone of modern software development. In this tutorial, we'll build a complete pipeline using GitHub Actions and Shipyard.
What You'll Learn
By the end of this tutorial, you'll have a fully automated pipeline that:
- Runs tests on every pull request
- Builds and deploys to staging on merge to main
- Promotes to production with a single click
Prerequisites
Before we start, make sure you have:
- A GitHub account with a repository
- A Shipyard account (free tier works fine)
- Basic familiarity with YAML syntax
Step 1: Create Your Workflow File
Create a new file at .github/workflows/deploy.yml in your repository:
name: Deploy to Shipyard
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- run: npm ci
- run: npm test
deploy:
needs: test
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Deploy to Shipyard
run: npx shipyard deploy
env:
SHIPYARD_TOKEN: ${{ secrets.SHIPYARD_TOKEN }}
Step 2: Configure Secrets
Go to your repository Settings → Secrets → Actions and add:
- SHIPYARD_TOKEN: Your API token from the Shipyard dashboard
"Automation is not about replacing humans, it's about freeing them to do more meaningful work."
— DevOps Handbook
Step 3: Add Environment Protection
For production deployments, add manual approval:
deploy-production:
needs: deploy-staging
runs-on: ubuntu-latest
environment:
name: production
url: https://your-app.shipyard.dev
steps:
- uses: actions/checkout@v4
- run: npx shipyard deploy --env production
Best Practices
- Keep workflows fast: Cache dependencies to speed up builds
- Use matrix builds: Test across multiple Node versions
- Add status badges: Show build status in your README
- Monitor failures: Set up Slack/Discord notifications
Conclusion
You now have a production-ready CI/CD pipeline! Every push to main will automatically deploy your application to Shipyard. For more advanced configurations, check out our documentation.