How to Use Shopify CLI in GitLab CI/CD Integration

I’m building theme app extension for an existing app. Below is what I did.

  1. Create app with shopify cli
  2. Scaffold theme app extension
  3. Run deploy from local, this will generate the .env in root. In this step you can create a new app or add the extension to an already existing app.

Here is a sample gitlab ci/cd that worked for me.

image: node:18

cache:
  paths:
  - node_modules/

stages:
  - install
  - deploy

install_dependencies:
  stage: install
  script:
    - npm install

deploy-job:  
  stage: deploy
  variables:
    SHOPIFY_API_KEY: 
    SHOPIFY_WIDGETS_ID: 
    SHOPIFY_CLI_PARTNERS_TOKEN: 
  script:
    - apt-get update
    - apt-get -y install ruby-full build-essential
    - gem install bundler
    - npm run deploy