Skip to content

Commit 7ed1d51

Browse files
committed
Shopify theme deployment post added
1 parent aa110e1 commit 7ed1d51

1 file changed

Lines changed: 94 additions & 0 deletions

File tree

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
---
2+
layout: post
3+
title: Deploy a Shopify theme to multiple stores from a single repository
4+
date: 2026-03-23 21:28:22.313771392 +0000
5+
description: How to deploy a Shopify theme to multiple stores from a single repository without overwriting content on each store.
6+
categories: shopify development
7+
tags: [shopify, theme development, github actions, ci/cd]
8+
---
9+
10+
## The problem
11+
12+
Sometimes we want the same theme code deployed to multiple stores. For example, you might have a live store and a staging store, or you might have multiple live stores for different regions that all use the same theme code but have different content.
13+
14+
This is not possible using the [native Shopify GitHub integration](https://shopify.dev/docs/storefronts/themes/tools/github){:target="_blank" :rel="noopener"}. This is because the native integration only allows you to connect one store to a GitHub repository.
15+
16+
Even if you could connect multiple stores, changing the content on one store would push that change back to the repository and then that change would be deployed to all the other stores, in most cases this is not desirable as it doesn't allow you to have different content on each store.
17+
18+
## The solution
19+
20+
Instead of using the native Shopify GitHub integration, we can use the Shopify CLI in a CI/CD pipeline (in this case, GitHub Actions) to deploy to multiple stores. This allows us to deploy the same theme code to multiple stores without overwriting the content on each store.
21+
22+
## Setup
23+
24+
This guide is for theme code hosted on GitHub.
25+
26+
The first step, if it's in use, is to disconnect the store from the GitHub repository in the Shopify admin.
27+
28+
Next you will need to install the [Shopify Theme Access app](https://apps.shopify.com/theme-access){:target="_blank" :rel="noopener"} on each store and generate a password for each store. This effectively gives you an API key with permissions to theme_read and theme_write.
29+
30+
Save these passwords in [GitHub secrets](https://docs.github.com/en/actions/how-tos/write-workflows/choose-what-workflows-do/use-secrets){:target="_blank" :rel="noopener"}, for example you could name them `STORE_1_PASSWORD`, `STORE_2_PASSWORD`, etc.
31+
32+
Once you have your secrets set up, you can set up a GitHub Actions workflow to deploy to multiple stores. Create a new yaml file in your repository's `.github/workflows` directory. e.g. `.github/workflows/deploy-theme.yml`
33+
34+
You can use the following workflow as a starting point:
35+
36+
```yaml
37+
name: Deploy theme
38+
on:
39+
workflow_dispatch:
40+
push:
41+
branches: [ main ]
42+
env:
43+
FLAGS: --ignore config/settings_data.json --ignore templates/*.json --ignore locales/* --ignore sections/*.json
44+
jobs:
45+
deploy:
46+
name: Deploy ${{ matrix.name }}
47+
runs-on: ubuntu-latest
48+
strategy:
49+
matrix:
50+
include:
51+
- name: "Store 1"
52+
theme_id: 000000000000
53+
store: store1
54+
secret: STORE_1_PASSWORD
55+
use_flags: true
56+
- name: "Store 2"
57+
theme_id: 000000000000
58+
store: store2
59+
secret: STORE_2_PASSWORD
60+
use_flags: true
61+
steps:
62+
- name: Checkout repository
63+
uses: actions/checkout@v4
64+
- uses: actions/setup-node@v4
65+
with:
66+
node-version: 24
67+
- name: Install Shopify CLI
68+
run: npm install -g @shopify/cli
69+
- name: Deploy theme
70+
run: |
71+
shopify theme push \
72+
--allow-live \
73+
--nodelete \
74+
--theme ${{ matrix.theme_id }} \
75+
--store ${{ matrix.store }} \
76+
${{ matrix.use_flags && env.FLAGS || '' }} \
77+
--password ${{ secrets[matrix.secret] }}
78+
```
79+
80+
This flow is triggered either on a push to the `main` branch or manually through the GitHub Actions interface. It will deploy the theme to each store defined in the matrix, using the corresponding password from the secrets.
81+
82+
For each store, you must make sure the configuration in the `matrix` is correct:
83+
84+
- `theme_id`: The ID of the theme you want to deploy to on that store. You can find this in the URL when editing the theme in the Shopify admin.
85+
- `store`: The myshopify domain of the store, without the `.myshopify.com` part. e.g. if your store is `example-store.myshopify.com`, you would put `example-store` here.
86+
- `secret`: The name of the GitHub secret where you stored the password for that store.
87+
88+
Once this file is set up and pushed to the repository, the workflow will run and deploy the theme to each store. You can check the progress and results of the workflow in the GitHub Actions tab of your repository.
89+
90+
## Further explanation
91+
92+
The `FLAGS` environment variable is used to specify which files to ignore during deployment. In this example, we are ignoring `config/settings_data.json`, all JSON templates, all JSON locales, and all JSON sections. This allows us to deploy the same theme code to multiple stores without overwriting the content on each store, as these files often contain store-specific content. At the time of writing, these are the only files that are written to from changes made in the Shopify admin.
93+
94+
Within the store `matrix`, `use_flags` is a boolean value that determines whether to use the `FLAGS` environment variable. This is useful if you want to deploy to some stores with the flags and some without. For example, you might want to deploy to a staging store without the flags so that you can test changes to content before deploying those changes to the live store with the flags enabled.

0 commit comments

Comments
 (0)