Automatic Git version control for Shopify settings_data.json
via CI/CD. Create a dedicated repo to backup settings_data.json
for a Shopify store.
Designed to work with Shopify Theme Lab.
A GitHub action runs automatically once during the specified interval. It downloads the settings_data.json
file from the provided Shopify store. If the remote file has changed, it's committed and then pushed to this repo, if not, nothing happens. This project has a similar directory structure to Shopify Theme Lab, you will find the settings file in shopify/config/settings_data.json
once it's added to this repo.
First, make sure the theme is already initialized on the Shopify store in question
- “Use this template” to create a new repository on GitHub
- Add the following four secrets to your Shopify Theme Lab repo in
settings
→secrets
:
SHOPIFY_API_PASSWORD # your-api-password
SHOPIFY_STORE_URL # your-store.myshopify.com
SHOPIFY_ENV # dev or live
SHOPIFY_THEME_ID # theme-id (without quotation marks) - find the id either in shopify.[env].config.yml or with shopify:themes task in your Shopify Theme Lab project
- Test the action by going to
actions
→Shopify Settings Control
and click onRun workflow
If you want to back up the settings for the published/main theme, pass the --main
flag (shorthand -m
) instead of the --id
/ -i
option when initializing the config:
npx themelab shopify:init -p ${{ secrets.SHOPIFY_API_PASSWORD }} -s ${{ secrets.SHOPIFY_STORE_URL }} -e ${{ secrets.SHOPIFY_ENV }} -m
By default, the action is set to run once every hour. You can adjust the cron
schedule inside shopify-settings-control.yml to change the interval.
on:
schedule:
- cron: "*/60 * * * *"
┌───────────── minute (0 - 59)
│ ┌───────────── hour (0 - 23)
│ │ ┌───────────── day of the month (1 - 31)
│ │ │ ┌───────────── month (1 - 12)
│ │ │ │ ┌───────────── day of the week (0 - 6)
│ │ │ │ │
│ │ │ │ │
│ │ │ │ │
* * * * *
An asterisk *
means that the field is considered “any time” - so * * * * *
means every minute of every day. Note that, at least on GitHub, times are based in UTC so you may have to do some timezone conversion!
To visualize chron expressions you can use crontab.guru.