Skip to main content

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.


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 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):

    NameRequired?Value
    SHOPIFY_CLI_THEME_TOKENYesThe Theme Access password that you generated or were given by a merchant
    SHOPIFY_FLAG_STOREYesThe store that you want to interact with
    SHOPIFY_FLAG_FORCENoPass this variable with a value of 1 to turn off interactive prompts. You may want to use this variable if your Shopify CLI pipeline step is timing out.

    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.

  • 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 (GitHub 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.

.github/workflows/deploy-theme.yml

name: Theme deploy

on: [push]

jobs:
deploy:
name: Deploy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20

- name: Install Shopify CLI
run: npm install -g @shopify/cli

- name: Upload theme
run: |
shopify theme push \
--json \
--theme your-theme-name-or-id \
--store ${{ secrets.SHOPIFY_FLAG_STORE }} \
--password ${{ secrets.SHOPIFY_CLI_THEME_TOKEN }}

Was this page helpful?