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
- Sign up at buddy.works
- Connect your Git provider (GitHub, GitLab, Bitbucket)
- Select your theme repository
2. Create New Project
Project Name: my-shopify-themeRepository: github.com/username/my-theme3. 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 DevelopmentTrigger: On push to develop
Actions: 1. Shopify CLI - Command: theme push - Theme: Development theme - Store: my-store.myshopify.comBuddy Visual Configuration
-
Add Pipeline
- Name: βDeploy to Developmentβ
- Trigger: On push
- Branch:
develop
-
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 DeployTrigger: 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 ReleaseTrigger: 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
- Go to Shopify Partners Dashboard
- Navigate to Apps β CLI Tokens
- Create new token for Buddy
Configure in Buddy
- Go to Project Settings β Variables
- Add variable:
- Name:
SHOPIFY_CLI_THEME_TOKEN - Value: Your token
- Type: Secret
- Name:
Use in Pipeline
Environment Variables: SHOPIFY_CLI_THEME_TOKEN: ${SHOPIFY_CLI_THEME_TOKEN}Multi-Store Deployment
Pipeline: Deploy to Multiple Stores
Pipeline: Multi-Store DeploymentTrigger: 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-updatesStaging Pipeline
Trigger: Push to release/*βββ Theme Check (strict)βββ Push to staging themeβββ Lighthouse auditβββ Notify: Slack #staging-reviewProduction Pipeline
Trigger: Push to mainβββ Theme Check (strict)βββ Backup current themeβββ Push to live themeβββ Smoke testsβββ Notify: Slack #releasesAdvanced Actions
Lighthouse Audit
Action: Lighthouse CIType: 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 NotificationChannel: #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 ProductionCondition: Only when tag matches v*
Action: Send AlertCondition: On failurePipeline Templates
Template: Feature Branch Preview
Pipeline: Feature PreviewTrigger: 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 BackupTrigger: 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 nameCustom 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
# Replicate Buddy environment locallyexport SHOPIFY_CLI_THEME_TOKEN="your-token"shopify theme checkshopify theme push --developmentManual Trigger
Run pipelines manually to test:
- Go to Pipeline
- Click βRunβ
- Select branch/tag
- Monitor execution
Best Practices
1. Always Run Theme Check First
# Fail fast if there are issues1. Theme Check Fail on: errors (or warnings for production)2. Backup Before Production Deploy
# Always have a rollback option1. Backup Current Theme2. Deploy New Version3. Use Separate Pipelines per Environment
develop β Development Pipelinerelease/* β Staging Pipelinemain β Production Pipeline4. Notify on All Outcomes
On Success: "β
Deployed successfully"On Failure: "β Deployment failed"Practice Exercise
Set up a complete CI/CD workflow:
- Create Buddy account and connect repo
- Create development deployment pipeline
- Create production deployment pipeline with backup
- Add Slack notifications
- Test complete workflow
Key Takeaways
- Buddy has native Shopify support for easy setup
- Pipelines automate repetitive tasks
- Multiple environments need separate pipelines
- Theme Check should run before every deploy
- Backups protect against bad deployments
- Notifications keep team informed
- 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...