Deploy extensions in a CD pipeline
If you have an app extension that you want to deploy to Shopify regularly, then you can integrate Shopify CLI into your CI/CD pipeline to programmatically deploy your app components using the
You can deploy any app extensions that you generated using Shopify CLI in a CI/CD pipeline.
Note that the
deploy command deploys all of the extensions in your project at once. You can't deploy a specific extension.
What you'll learnAnchor link to section titled "What you'll learn"
In this tutorial, you'll learn how to set up your CI/CD pipeline to deploy your app extensions programmatically. To do so, you'll gather the information necessary to run the CLI commands, and then add a step to your CI/CD pipeline that installs Shopify CLI and pushes your app extensions to Shopify.
RequirementsAnchor link to section titled "Requirements"
Step 1: Generate variables for deploymentAnchor link to section titled "Step 1: Generate variables for deployment"
To target the app that you want to deploy to, you need to gather your app's client ID.
- Navigate to your app directory.
Run the following command:
env file is generated at the root of your project. It contains the client ID (API key) for your app and the ID of each of the extensions in your app.
Step 2: Generate a CLI authentication tokenAnchor link to section titled "Step 2: Generate a CLI authentication token"
You can create a new CLI authentication token through the Partner Dashboard.
Tokens are managed at the Partner organization level. You can have only two CLI authentication tokens for your Partner organization. If you want to create more than two authentication tokens, then you need to delete an existing authentication token.
Generate a CLI authentication token in the Partner DashboardAnchor link to section titled "Generate a CLI authentication token in the Partner Dashboard"
- From your Partner Dashboard, navigate to Settings > CLI token, and then click Manage tokens.
Select the appropriate access for your authentication token:
- UI extensions: For UI extensions, including Checkout UI, Post-purchase UI, Subscription UI, and Web pixel.
- Functions: For Shopify Functions-based extensions such as order, product, or shipping discounts.
After the token is created, these permissions can't be changed.
From the Token expiration drop-down list, select an expiration for the token.
Click Generate token.
In the Tokens section, click the Copy button to copy the access token to your clipboard.
This token value will be passed as a parameter in your Shopify CLI automation.
For security reasons, the token is only visible immediately after it's created. If you lose your token, then you need to delete your existing token and then generate a new token.
Step 3: Integrate Shopify CLI into your pipelineAnchor link to section titled "Step 3: Integrate Shopify CLI into your pipeline"
After you retrieve your deployment variables and CLI authentication token, 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 push to Shopify programmatically using your CD pipeline step, include the following:
- An environment variable that contains the authentication token that you generated in the Partner Dashboard.
- The client ID for your app.
A step that sets up Node.js and installs your project's Node dependencies. The package manager that you use should match your project's lockfile.
- If you're using GitHub Actions, then you can use actions/setup-node.
- If you're using CircleCI, then you can use circleci/node.
Steps that install the other dependencies for your project.
A step that runs the CLI
Where possible, you should protect the authentication token and client ID values by masking them or storing them as secrets.
Additional project dependenciesAnchor link to section titled "Additional project dependencies"
The dependencies that are required to deploy your app extension depend on the technologies that you use to build the extension. Below are examples of common additional dependencies you'll need:
|App extension type||Additional dependencies|
|Theme blocks||Ruby, Bundler|
|Extensions that use Shopify Functions, including product, order, and shipping discount extensions||Your function language|
The sections below provide examples of common CI/CD pipeline tools: GitHub Actions and CircleCI.
GitHub ActionsAnchor link to section titled "GitHub Actions"
Below is an example of a step that you might add to your GitHub Actions workflow. It pushes extension code to Shopify when code is pushed to the
The package manager that you use in your GitHub Action should match your project's lockfile.
The following config file defines a job that's triggered by a CircleCI workflow.
The package manager that you use in your job should match your project's lockfile.