Quality, Performance, Accessibility, and Shipping Intermediate 15 min read

Automated Deployment with Buddy CI/CD

Set up continuous integration and deployment for Shopify themes using Buddy, automating testing, theme check, and deployment workflows.

Automated deployment eliminates manual errors and ensures consistent quality. Buddy is a CI/CD platform with excellent Shopify integration, making it ideal for theme deployment workflows.

Why Automate Deployment?

Manual Deployment Problems

  • Human error (wrong theme, wrong store)
  • Inconsistent processes
  • Forgotten quality checks
  • Time-consuming repetitive tasks

Automation Benefits

  • Consistent quality gates
  • Faster deployments
  • Automatic testing
  • Audit trail
  • Team collaboration

Buddy Overview

Buddy is a CI/CD platform that:

  • Has native Shopify CLI integration
  • Provides visual pipeline builder
  • Offers Git-based triggers
  • Supports multiple environments

Setting Up Buddy

1. Create Buddy Account

  1. Sign up at buddy.works
  2. Connect your Git provider (GitHub, GitLab, Bitbucket)
  3. Select your theme repository

2. Create New Project

Project Name: my-shopify-theme
Repository: github.com/username/my-theme

3. Create Pipeline

Pipelines define automated workflows triggered by Git events.

Basic Deployment Pipeline

Pipeline: Deploy to Development

Trigger: Push to develop branch

# Pipeline configuration (visual builder creates this)
Pipeline: Deploy to Development
Trigger: On push to develop
Actions:
1. Shopify CLI
- Command: theme push
- Theme: Development theme
- Store: my-store.myshopify.com

Buddy Visual Configuration

  1. Add Pipeline

    • Name: β€œDeploy to Development”
    • Trigger: On push
    • Branch: develop
  2. Add Action: Shopify CLI

    • Action type: Shopify CLI
    • Command: theme push
    • Store URL: my-store.myshopify.com
    • Theme ID: Your development theme ID
    • Add Shopify CLI token (from Partner Dashboard)

Full CI/CD Pipeline

Pipeline: Quality + Deploy

Pipeline: Quality Check and Deploy
Trigger: On push to develop
Actions:
1. Run Theme Check
Type: Shopify CLI
Command: shopify theme check
2. Push to Development Theme
Type: Shopify CLI
Command: shopify theme push
Theme ID: dev-theme-id
Ignore: config/settings_data.json
3. Slack Notification
Type: Slack
Message: "Theme deployed to development"

Pipeline: Production Release

Pipeline: Production Release
Trigger: On push to main
Actions:
1. Run Theme Check
Type: Shopify CLI
Command: shopify theme check
Fail on: warnings
2. Backup Current Theme
Type: Shopify CLI
Command: shopify theme pull --live
Output: ./backup
3. Upload Backup
Type: Upload to S3/Storage
Source: ./backup
4. Deploy to Production
Type: Shopify CLI
Command: shopify theme push --live
Ignore: config/settings_data.json
5. Notify Team
Type: Slack
Message: "πŸš€ Theme v${VERSION} deployed to production"

Shopify CLI Authentication

Get CLI Token

  1. Go to Shopify Partners Dashboard
  2. Navigate to Apps β†’ CLI Tokens
  3. Create new token for Buddy

Configure in Buddy

  1. Go to Project Settings β†’ Variables
  2. Add variable:
    • Name: SHOPIFY_CLI_THEME_TOKEN
    • Value: Your token
    • Type: Secret

Use in Pipeline

Environment Variables:
SHOPIFY_CLI_THEME_TOKEN: ${SHOPIFY_CLI_THEME_TOKEN}

Multi-Store Deployment

Pipeline: Deploy to Multiple Stores

Pipeline: Multi-Store Deployment
Trigger: Manual or on tag
Actions:
1. Theme Check
Command: shopify theme check
2. Deploy to Store A
Store: store-a.myshopify.com
Theme ID: 123456789
3. Deploy to Store B
Store: store-b.myshopify.com
Theme ID: 987654321
4. Summary Notification
Message: "Deployed to 2 stores"

Environment-Specific Pipelines

Development Pipeline

Trigger: Push to develop
β”œβ”€β”€ Theme Check
β”œβ”€β”€ Push to dev theme
└── Notify: Slack #dev-updates

Staging Pipeline

Trigger: Push to release/*
β”œβ”€β”€ Theme Check (strict)
β”œβ”€β”€ Push to staging theme
β”œβ”€β”€ Lighthouse audit
└── Notify: Slack #staging-review

Production Pipeline

Trigger: Push to main
β”œβ”€β”€ Theme Check (strict)
β”œβ”€β”€ Backup current theme
β”œβ”€β”€ Push to live theme
β”œβ”€β”€ Smoke tests
└── Notify: Slack #releases

Advanced Actions

Lighthouse Audit

Action: Lighthouse CI
Type: Custom script
Script: |
npm install -g @lhci/cli
lhci autorun --config=lighthouserc.json
Lighthouse Config (lighthouserc.json):
{
"ci": {
"collect": {
"url": ["https://my-store.myshopify.com/"]
},
"assert": {
"preset": "lighthouse:recommended",
"assertions": {
"categories:performance": ["error", {"minScore": 0.8}]
}
}
}
}

Custom Notifications

Action: Slack Notification
Channel: #theme-deployments
Message: |
πŸš€ *Theme Deployment*
Repository: ${BUDDY_REPO_SLUG}
Branch: ${BUDDY_EXECUTION_BRANCH}
Commit: ${BUDDY_EXECUTION_REVISION_SHORT}
Author: ${BUDDY_INVOKER_NAME}
Status: ${BUDDY_EXECUTION_STATUS}

Conditional Actions

Action: Deploy to Production
Condition: Only when tag matches v*
Action: Send Alert
Condition: On failure

Pipeline Templates

Template: Feature Branch Preview

Pipeline: Feature Preview
Trigger: Push to feature/*
Actions:
1. Create Preview Theme
Command: shopify theme push --unpublished
Name: "Preview: ${BRANCH_NAME}"
2. Comment on PR
Type: GitHub Comment
Message: "Preview ready: https://admin.shopify.com/themes/${THEME_ID}/editor"

Template: Nightly Backup

Pipeline: Nightly Backup
Trigger: Schedule (daily at 2am)
Actions:
1. Pull Live Theme
Command: shopify theme pull --live
2. Archive Theme
Command: tar -czf theme-$(date +%Y%m%d).tar.gz ./theme
3. Upload to S3
Bucket: theme-backups
Path: backups/${DATE}/

Buddy Variables

Built-in Variables

${BUDDY_EXECUTION_BRANCH} - Branch name
${BUDDY_EXECUTION_REVISION} - Full commit SHA
${BUDDY_EXECUTION_REVISION_SHORT} - Short commit SHA
${BUDDY_INVOKER_NAME} - Who triggered
${BUDDY_EXECUTION_START_DATE} - Timestamp
${BUDDY_PROJECT_NAME} - Project name

Custom Variables

Project Variables:
SHOPIFY_STORE: my-store.myshopify.com
DEV_THEME_ID: 123456789
STAGING_THEME_ID: 987654321
PRODUCTION_THEME_ID: live
Usage in Actions:
Store: ${SHOPIFY_STORE}
Theme ID: ${DEV_THEME_ID}

Handling Secrets

Secure Variable Storage

Secrets (encrypted):
SHOPIFY_CLI_THEME_TOKEN: ****
SLACK_WEBHOOK_URL: ****
AWS_ACCESS_KEY: ****

Access in Actions

Environment Variables:
SHOPIFY_CLI_THEME_TOKEN: ${SHOPIFY_CLI_THEME_TOKEN}

Debugging Pipelines

View Execution Logs

Buddy provides detailed logs for each action:

  • Command output
  • Error messages
  • Timing information

Test Actions Locally

Terminal window
# Replicate Buddy environment locally
export SHOPIFY_CLI_THEME_TOKEN="your-token"
shopify theme check
shopify theme push --development

Manual Trigger

Run pipelines manually to test:

  1. Go to Pipeline
  2. Click β€œRun”
  3. Select branch/tag
  4. Monitor execution

Best Practices

1. Always Run Theme Check First

# Fail fast if there are issues
1. Theme Check
Fail on: errors (or warnings for production)

2. Backup Before Production Deploy

# Always have a rollback option
1. Backup Current Theme
2. Deploy New Version

3. Use Separate Pipelines per Environment

develop β†’ Development Pipeline
release/* β†’ Staging Pipeline
main β†’ Production Pipeline

4. Notify on All Outcomes

On Success: "βœ… Deployed successfully"
On Failure: "❌ Deployment failed"

Practice Exercise

Set up a complete CI/CD workflow:

  1. Create Buddy account and connect repo
  2. Create development deployment pipeline
  3. Create production deployment pipeline with backup
  4. Add Slack notifications
  5. Test complete workflow

Key Takeaways

  1. Buddy has native Shopify support for easy setup
  2. Pipelines automate repetitive tasks
  3. Multiple environments need separate pipelines
  4. Theme Check should run before every deploy
  5. Backups protect against bad deployments
  6. Notifications keep team informed
  7. Variables keep secrets secure

What’s Next?

The final lesson is the Capstone Project where you’ll build, deploy, and document a complete theme.

Finished this lesson?

Mark it complete to track your progress.

Discussion

Loading comments...