Shopify / cli

Build apps, themes, and hydrogen storefronts for Shopify
https://shopify.dev
MIT License
408 stars 124 forks source link

[Feature]: Multiple Stores Using Same Github Branch #3509

Open skyproddev opened 6 months ago

skyproddev commented 6 months ago

What area(s) will this request affect?

Deployment

What type of change do you want to see?

Substantial change to existing feature

Overview

As many people have found (see articles linked at the bottom) there are issues about running the same theme on multiple GitHub branches, for multiple stores. But that setup is a very common scenario for us devs.

The problem

The problem is simply summed up in that the theme's json files (that holds settings/customizations) will be individually altered by the integrated themes and pushed from Shopify to GitHub. If I then push new code edits from my dev theme to the live branches, there will mostly be conflicts. Going through these conflicts individually is cumbersome, and prone to errors. (For example: If the local json files have been altered while testing and developing, and there is no conflict, because develop is ahead of live branches — then the test settings are accidentally merged to live themes without conflict.)

The solutions suggested in the various articles come so close to an automated version, enabling us to ignore config/json, templates/json and locales/*json, but it doesn't quite land. I've spent hours trying to automate the flow for one client, but I reach a dead end each time I think I almost made it.

The solution

I have no specific suggestion as to how to solve it, but I first wanted to gauge the interest and see if this feature request gains some traction. And also by linking all the articles below, I want to highlight that this is an issue that many people have dived into deeply, without luck.

Maybe the solution would be something about how the Shopify GitHub integration interacts with .gitignore files. Maybe it would be something in the CLI itself. But this scenario is well worth a solution, since almost any international store benefits from this.

Conversations around this topic, which all lead to the same dead end (except maybe one very complex setup outside of the Shopify eco-system, which I have not personally tested):

Motivation

Trying to maintain and develop the same theme over multiple stores, using GitHub branches, without overriding settings pushed from the Shopify GitHub integration.

skyproddev commented 6 months ago

Right after I published this, I found a fantastic GitHub action written for this very purpose: https://github.com/Jamiemccleave/shopify-multi-store-deployer

Thank you Jamie!!

It works like a charm and solves the problem precisely!

nboliver-ventureweb commented 5 months ago

@skyproddev Does your theme have an asset build step? How do you handle that, if so?

skyproddev commented 5 months ago

@skyproddev Does your theme have an asset build step? How do you handle that, if so?

Nowadays I try to follow the structure of the newest Dawn version, where it's regular uncompiled css and js, and it's split up into many files, which are included in individual sections. But I have used webpack and gulp and stuff back in the days. Then I just put it in a dev folder and keep it on github along with the theme. Its not a problem. The Shopify github connection will ignore files in a folder that's not in their structure, so it stays only on your local machine and on github.

Jamiemccleave commented 5 months ago

@skyproddev Thanks!

jeffreyguenther commented 5 months ago

@skyproddev Looks like you've found a solution that works for you.

If you're curious about an alternative solution check out Shopkeeper. It takes a slightly different approach that treats main as the source of truth and your theme folder as a 'build artifact'.

github-actions[bot] commented 4 months ago

This issue seems inactive. If it's still relevant, please add a comment saying so. Otherwise, take no action. → If there's no activity within a week, then a bot will automatically close this. Thanks for helping to improve Shopify's dev tooling and experience.

P.S. You can learn more about why we stale issues here.

github-actions[bot] commented 2 months ago

This issue seems inactive. If it's still relevant, please add a comment saying so. Otherwise, take no action. → If there's no activity within a week, then a bot will automatically close this. Thanks for helping to improve Shopify's dev tooling and experience.

P.S. You can learn more about why we stale issues here.

hannahbeasley commented 2 months ago

This is an issue for our agency as well! Another consideration for us is the idea of third party apps being able to edit code themselves - and those changes are of course always pushed to Github. If we have an app installed on one store but not another, we don't want the app edits showing up on a store that's not using that app.

But at the end of the day, what's most important for us is to be able to streamline theme updates. One of our clients has two sites that are essentially identical at the code level, and just have varying content and apps. It's inefficient for us to manually manage separate branches for each store, when updates at the theme level from our side will always apply to both sites. So being able to use a single branch for both sites would save us a lot of time.

I think it would be ideal if Shopify contextualized all files that store content (layout files, templates, section groups) and made a way for that to optionally be protected at the store level while still allowing all other theme content to be shared as needed.

leon-schnieders commented 1 month ago

We need this too, as we have a couple of very similar shops. I suggest a solution similar to custom apps for managing themes across multiple stores. "Custom themes" could be published to all stores in a Shopify Plus organization with a single install link and updated centrally. This would streamline updates and maintain store-specific settings.

Looking forward to updates on this thread!

kfalkiewicz commented 1 month ago

For me this is also crucial, as most of the Polish Shopify stores needs second store account for international payments (no Shopify Payments support in Poland yet). This is a common problem here. Of course 1 merchant uses 1 theme for both the accounts and want's to have the same codebase on both.