Shopifyのテーマ拡張機能をCI/CDサービスからデプロイする | Tsun Inc.

Deploy Shopify theme extensions from a CI/CD service

小笠原 京平

I'm Ogasawara, CTO of Tsun Inc.
This time, I will introduce the procedure for deploying a Shopify app theme extension from CI.
I hope this will be helpful for those who are currently developing theme extensions and those who will develop them in the future.

Why do this?

To develop a Shopify theme extension, you deploy it to Shopify separately from the Shopify app.
(Liquid and JavaScript files for theme extensions are served from Shopify's servers.)

You also need to publish the theme extension from the Shopify Partner admin after deployment.

By automating the deployment process, you can prevent missed theme extension updates and publishing mistakes to some extent.
(However, the process of publishing a theme extension from the Shopify Partner admin cannot be automated.)

Prerequisites

Target audience

  • People developing a theme extension for a Shopify app

Environment

  • Shopify CLI: Version 3.39.0
  • Package manager: npm

Things to prepare

  • A theme extension for a Shopify app
  • A CI/CD service (GitHub Actions, CircleCI, etc.)

Procedure

There is an official guide on the Shopify Developers Platform, so in general, you can follow the steps there.

Get the theme extension ID

* If you have already deployed it before, you can skip this step.

With the theme extension already implemented, run the following command.

npm run deploy

With the latest CLI, there are prompts such as whether to deploy the theme extension, and when deployment is complete, SHOPIFY_THEME_EXTENSION_ID is added to .env.
This is an ID created for each theme extension. During deployment, the theme extension is identified and deployed based on SHOPIFY_API_KEY and this ID.

Get a CLI token

  1. From the Shopify Partner admin, click Manage tokens under Settings > CLI tokens.
  2. Click Generate CLI token and copy the generated token.

Deploy with a CI/CD service

Run the deployment with a CI/CD service.
At that time, you need the SHOPIFY_THEME_EXTENSION_ID, CLI token, and SHOPIFY_API_KEY obtained above.
Configure them so that SHOPIFY_API_KEY, SHOPIFY_THEME_EXTENSION_ID, and SHOPIFY_CLI_PARTNERS_TOKEN can each be retrieved from environment variables.

Once the environment variables are set, running the deploy command makes it possible to deploy the theme extension from CI.

One note: when deploying a theme extension, Shopify CLI checks the theme extension. Because that check runs in Ruby, you need to run the deployment in an environment where Ruby and Bundler can run.

Also, since CLI v3.40.0, you need to add the -f flag to the deploy command.

As an example, here is a Dockerfile that installs Node in a Ruby-based image file.
It is OK if you prepare an environment like this in your CI/CD service where Ruby and Node can be used.

FROM ruby:3.1-bullseye as extension

ARG SHOPIFY_API_KEY
ENV SHOPIFY_API_KEY=$SHOPIFY_API_KEY
ARG SHOPIFY_CLI_PARTNERS_TOKEN
ENV SHOPIFY_CLI_PARTNERS_TOKEN=$SHOPIFY_CLI_PARTNERS_TOKEN
ARG SHOPIFY_THEME_EXTENSION_ID
ENV SHOPIFY_THEME_EXTENSION_ID=$SHOPIFY_THEME_EXTENSION_ID

RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && apt-get install -y nodejs
WORKDIR /app
COPY . .
RUN cd extensions/theme-extension && npm ci && npm run build
RUN npm ci && npm run deploy -- --force

Summary

This time, I introduced how to deploy a Shopify theme extension from a CI/CD service.
Once you set up deployment automation and similar workflows, they continue to improve work efficiency and prevent human error, so be sure to set them up.

Tsun Inc. develops Shopify apps used by stores around the world.
If you are interested in requesting Shopify app development or hiring us, please contact Tsun Inc.

👆️目次はShopifyアプリ「RuffRuff 目次作成」を利用

👆️Table of contents by the Shopify app RuffRuff Table of Contents

Back to blog
  • Shopifyで使える決済方法一覧|手数料・導入サービス・選び方

    [Complete Guide] A Roundup of Payment Methods A...

    Tsunライターチーム

    This article gives a detailed explanation of the many payment methods available on Shopify and their respective payment processing fees and transaction fees. We also introduce handy Shopify apps that...

    [Complete Guide] A Roundup of Payment Methods A...

    Tsunライターチーム

    This article gives a detailed explanation of the many payment methods available on Shopify and their respective payment processing fees and transaction fees. We also introduce handy Shopify apps that...

  • GMOイプシロンの手数料・決済方法・入金サイクル|Shopifyの条件も解説

    GMO Epsilon Fees, Payment Methods, and Payout C...

    Tsun ライターチーム

    GMO Epsilon payment methods and fees, organized by contract type. Covers Shopify-specific terms, payouts, authorization and capture deadlines, refunds, and cancellation. Also introduces ways to use apps to control which...

    GMO Epsilon Fees, Payment Methods, and Payout C...

    Tsun ライターチーム

    GMO Epsilon payment methods and fees, organized by contract type. Covers Shopify-specific terms, payouts, authorization and capture deadlines, refunds, and cancellation. Also introduces ways to use apps to control which...

  • Shopify向けSBペイメントサービス|対応決済・手数料・導入時の注意点

    SB Payment Service for Shopify: Supported Payme...

    Tsun ライターチーム

    This article organizes the payment methods and pricing available with SBPS for Shopify. Compare cost estimates that include fixed costs, authentication fees, and Shopify fees, along with capture deadlines and...

    SB Payment Service for Shopify: Supported Payme...

    Tsun ライターチーム

    This article organizes the payment methods and pricing available with SBPS for Shopify. Compare cost estimates that include fixed costs, authentication fees, and Shopify fees, along with capture deadlines and...

  • KOMOJUとShopifyの連携|決済方法・手数料・オーソリ期限

    Integrating KOMOJU with Shopify: Payment Method...

    Tsunライターチーム

    This guide lists the KOMOJU payment methods available on Shopify and their fees. It covers rates for physical goods and digital content, additional Shopify fees, setup steps, authorization periods, payouts,...

    Integrating KOMOJU with Shopify: Payment Method...

    Tsunライターチーム

    This guide lists the KOMOJU payment methods available on Shopify and their fees. It covers rates for physical goods and digital content, additional Shopify fees, setup steps, authorization periods, payouts,...

  • Shopifyのセキュリティ対策|決済・アプリ要件・バグバウンティ

    Shopify Security: Payments, App Requirements, a...

    Tsun ライターチーム

    For businesses considering Shopify, this article explains security safeguards for communications, customer information, payments, and apps, along with third-party assessments. Review the scope of protection, compensation requirements, operational preparations, and...

    Shopify Security: Payments, App Requirements, a...

    Tsun ライターチーム

    For businesses considering Shopify, this article explains security safeguards for communications, customer information, payments, and apps, along with third-party assessments. Review the scope of protection, compensation requirements, operational preparations, and...

  • Shopifyサーバーの費用・稼働率・障害時の対処法

    Shopify server costs, uptime, and how to respon...

    Tsun ライターチーム

    Shopify web hosting is included in the plan fee. This article organizes costs and the scope of management, the difference between official uptime figures and contractual guarantees, the checks to...

    Shopify server costs, uptime, and how to respon...

    Tsun ライターチーム

    Shopify web hosting is included in the plan fee. This article organizes costs and the scope of management, the difference between official uptime figures and contractual guarantees, the checks to...

1 of 6
  • AI仮想顧客の改善ツール「SimGym」を使ったら売上はどうなった?実行から3か月後までの記録

    What Happened to Sales After Using SimGym, an A...

    テキサス・アユミ

    A record of trying SimGym on the miso specialty store ドットミソ, from checking the proposals through carrying out changes to the look-back three months later. It covers how the order...

    What Happened to Sales After Using SimGym, an A...

    テキサス・アユミ

    A record of trying SimGym on the miso specialty store ドットミソ, from checking the proposals through carrying out changes to the look-back three months later. It covers how the order...

  • 【ストアインタビュー後編】やりながら育てるShopify。「野菜をMOTTO」の試行錯誤:モンマルシェ株式会社 河野雄士さん

    [Store Interview, Part 2] Building and Growing ...

    テキサス・アユミ

    "Even when e-commerce is the main battlefield, e-commerce isn't the goal." An in-depth look at our interview with Yuji Kono of Mon Marché, whose brand "Yasai wo MOTTO" grew its...

    [Store Interview, Part 2] Building and Growing ...

    テキサス・アユミ

    "Even when e-commerce is the main battlefield, e-commerce isn't the goal." An in-depth look at our interview with Yuji Kono of Mon Marché, whose brand "Yasai wo MOTTO" grew its...

  • 【ストアインタビュー前編】 ECが主戦場でも、ECが目的ではない。「野菜をMOTTO」が貫くEC戦略:モンマルシェ株式会社 河野雄士さん

    [Store Interview, Part 1] Even When E-Commerce ...

    テキサス・アユミ

    "Even when e-commerce is the main battlefield, e-commerce isn't the goal." Part 1 of our interview with Yuji Kono of Mon Marché, whose brand "Yasai wo MOTTO" grew its e-commerce...

    [Store Interview, Part 1] Even When E-Commerce ...

    テキサス・アユミ

    "Even when e-commerce is the main battlefield, e-commerce isn't the goal." Part 1 of our interview with Yuji Kono of Mon Marché, whose brand "Yasai wo MOTTO" grew its e-commerce...

1 of 3
  • Our Editorial Process

    For readers new to e-commerce and Shopify, we write our articles with care to explain difficult commerce and marketing terms, along with how everything works from building a store through to selling, as “gently,” “clearly,” and “accurately” as we can.

    Learn more 
  • About the information on this site

    The information published here is based on Tsun Inc.’s own experience and research. While we make every effort to publish information that is as “current” and “accurate” as possible, we cannot fully guarantee its contents. Tsun Inc. accepts no liability whatsoever for any damages arising from this site. If you find an error in the information published here, we would be grateful if you would contact Tsun Inc.