11
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Shopify 環境別deploy方法について

Last updated at Posted at 2020-09-26

はじめに

  • インストール等は割愛しております。
  • 使用ツールShopify Theme Kit
  • テーマIDの一覧を取得しておきます。
  • [live]とついているIDがShopify管理画面上での本番の事を意味しています。
$ theme get --list -p=パスワード -s=ストア名
  [11111111111] Debut
  [22222222222] Masonry
  [33333333333][live] Pacific
  • 目的のテーマIDをダウンロードしたい場合
$ theme get --list -p=パスワード -s=ストア名 -t=テーマID

設定ファイルの準備

  • テーマIDを設定ファイルに記載して準備します。

  • 余談ですが、初期設定時のconfig.ymlの環境名はdevelopmentとなっていて、ファイルの監視と自動更新を行うコマンドtheme watchdevelopmentに向いているようです。そのため下記のようにそれぞれの環境に自動更新するのではなくdevelopmentだけなので安心です。

  • 公式ドキュメント https://shopify.github.io/themekit/configuration/#config-file

config.yml
# 本番環境
production:
  password: パスワード
  theme_id: テーマID
  store: ストア名

# ステージング環境
staging:
  password: パスワード
  theme_id: テーマID
  store: ストア名

# 開発環境
development:
  password: パスワード
  theme_id: テーマID
  store: ストア名

環境別にdeploy

  • 続いて環境別にdeployする方法の説明です。
  • 基本的にdeployはtheme deployコマンドで実施します。
  • optionをつけないとdevelopmentの環境を更新します。
$ theme deploy
  • optionで–env=[環境名] を追加することで環境別にdeployしてくれます。
$ theme deploy --env=development
$ theme deploy --env=staging
$ theme deploy --env=production
  • また、個別ファイルを更新する方法の説明です。
  • 個別ファイルを更新したいこともあると思いますのでassets/ファイルを例にします。
$ theme deploy assets/ファイル --env=development
$ theme deploy assets/ファイル --env=staging
$ theme deploy assets/ファイル --env=production
  • すべての環境にまとめてdeployする方法です。
$ theme deploy -a

警告が出る場合

[production] 
This is the live theme on ライブテーマの名前.
If you wish to make changes to it, then you will have to pass the --allow-live flag
cannot make changes to a live theme without an override

解決
当然ながらテーマID[live]が含まれています

ライブテーマごとすべて変更したい場合は --allow-live フラグを渡す必要があります。

$ theme deploy -a --allow-live
11
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
11
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?