GitHub Actions CI/CD for E-Commerce Projects: Practical Workflows
How to use GitHub Actions for automated testing, deployment, and scheduled tasks in e-commerce applications.
Beyond Simple Deployments
GitHub Actions is more than a deployment pipeline. For e-commerce projects, it handles scheduled syncs, automated content generation, and monitoring — all without a dedicated server.
Workflow 1: Automated Deployment
Every push to main triggers a deployment to Railway:
name: Deploy to Railway
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Railway CLI
run: npm install -g @railway/cli
- name: Deploy
run: railway up
env:
RAILWAY_TOKEN: ${{ secrets.RAILWAY_TOKEN }}
Adding Tests Before Deploy
jobs:
test:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:15
env:
POSTGRES_PASSWORD: test
POSTGRES_DB: testdb
ports: ['5432:5432']
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- run: npm ci
- run: npm test
env:
DATABASE_URL: postgresql://postgres:test@localhost:5432/testdb
deploy:
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: npm install -g @railway/cli && railway up
env:
RAILWAY_TOKEN: ${{ secrets.RAILWAY_TOKEN }}
Workflow 2: Scheduled Inventory Sync
For Shopee-Shopify inventory synchronization, a cron-triggered workflow runs every 15 minutes:
name: Inventory Sync
on:
schedule:
- cron: '*/15 * * * *'
workflow_dispatch: {}
jobs:
sync:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- run: npm ci
- run: node scripts/sync-inventory.js
env:
SHOPIFY_TOKEN: ${{ secrets.SHOPIFY_TOKEN }}
SHOPEE_PARTNER_KEY: ${{ secrets.SHOPEE_PARTNER_KEY }}
DATABASE_URL: ${{ secrets.DATABASE_URL }}
Handling Failures
When a sync fails, you need to know immediately:
- name: Notify on failure
if: failure()
run: |
curl -X POST ${{ secrets.SLACK_WEBHOOK }} \
-H 'Content-Type: application/json' \
-d '{"text": "Inventory sync failed! Check: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"}'
Workflow 3: Daily Content Generation
The blog automation system generates one post per day:
name: Daily Blog Post
on:
schedule:
- cron: '0 6 * * *'
jobs:
generate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- run: npm ci
- run: node scripts/generate-blog-post.js
- name: Commit generated post
run: |
git config user.name "Blog Bot"
git config user.email "bot@example.com"
git add data/posts/
git diff --staged --quiet || git commit -m "Add daily blog post"
git push
Secrets Management
GitHub Actions secrets are encrypted and only exposed during workflow runs. Best practices:
- Use environment-specific secrets via GitHub Environments
- Rotate secrets regularly — especially API keys
- Never log secrets — use masking if debugging
- Limit access — require reviews for workflows that use production secrets
Caching for Speed
Node.js projects benefit enormously from dependency caching:
- uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
This caches node_modules based on package-lock.json, reducing install time from 30+ seconds to under 5 seconds.
Matrix Builds
Test across Node.js versions when building libraries or packages:
strategy:
matrix:
node-version: [18, 20, 22]
steps:
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
Cost Considerations
GitHub Actions provides 2,000 free minutes/month for private repos and unlimited minutes for public repos. For our e-commerce projects:
- Inventory sync (every 15 min): ~2,880 runs/month, ~1 min each = ~48 hours
- Blog generation (daily): ~30 runs/month, ~2 min each = ~1 hour
- Deployments: ~50 pushes/month, ~3 min each = ~2.5 hours
This fits well within GitHub's free tier for public repos and stays affordable for private ones.
Conclusion
GitHub Actions transforms your repository into a full automation platform. For e-commerce projects, it handles everything from deployment to scheduled syncs to content generation — all version-controlled alongside your code.