Use Shopify CLI in a CI/CD pipeline
If you have a theme that you want to work with programmatically, then you can integrate Shopify CLI into your CI/CD pipeline to perform actions like pushing, pulling, and publishing a theme.
Anchor to What you'll learnWhat you'll learn
In this tutorial, you'll learn how to set up your CI/CD pipeline to work with themes programmatically. To do so, you'll gather the credentials necessary to run the CLI commands, and then add a step to your CI/CD pipeline that installs Shopify CLI and runs CLI commands.
Anchor to RequirementsRequirements
Anchor to Step 1: Get a Theme Access password for the storeStep 1: Get a Theme Access password for the store
For each store that you want to interact with programmatically using Shopify CLI, you need to get a Theme Access password. These are generated using the Theme Access app.
To learn about the requirements for installing and using the Theme Access app, and instructions on how to generate a new password, refer to Manage theme access.
Anchor to Step 2: Integrate Shopify CLI into your pipelineStep 2: Integrate Shopify CLI into your pipeline
After you get a Theme Access password for the store, you can integrate Shopify CLI into your continuous deployment pipeline using your CI/CD provider.
The CD pipeline step should install Shopify CLI and all of its dependencies.
To run Shopify CLI theme commands programmatically using your CD pipeline step, include the following:
-
Environment variables (or equivalent flags):
Name Required? Value SHOPIFY_CLI_THEME_TOKENYes The Theme Access password that you generated or were given by a merchant SHOPIFY_FLAG_STOREYes The store that you want to interact with SHOPIFY_FLAG_NO_INPUTNo Pass this variable with a value of 1to turn off interactive prompts and browser authentication. A command that's missing required input fails instead of waiting for a response. You may want to use this variable if your Shopify CLI pipeline step is timing out.The
theme publish,theme delete, andtheme duplicatecommands ask for confirmation. To run them non-interactively, also pass--force(SHOPIFY_FLAG_FORCE). Thetheme pushcommand also accepts--forceto skip its confirmations when the current directory doesn't look like a theme directory, or when you push to multiple environments at once. The--forceflag only skips confirmations. It doesn't turn off other prompts, and it doesn't authorize a push to the live theme. To push to the live theme non-interactively, pass--allow-live(SHOPIFY_FLAG_ALLOW_LIVE).Where possible, you should protect the Theme Access password by masking it or storing it as a secret.
-
A step that sets up Node.js 22.12 or higher.
-
A step that installs Shopify CLI globally.
-
A step that runs the CLI command that you want to execute.
Anchor to Example (GitHub Actions)Example (Git Hub Actions)
Below is an example of a step that you might add to your GitHub Actions workflow. It pushes a theme to a Shopify store when code is pushed to the main branch.