Re: How to Use Shopify CLI in GitLab CI/CD Integration

How to Use Shopify CLI in GitLab CI/CD Integration

CodesDoNotLie
Visitor
3 0 2

Good day everyone!

 

I'm very new to Shopify & GitLab platforms and I don't exactly know how to properly integrate the new Shopify CLI with the GitLab CI/CD pipeline.

 

My goal is when I push the changes to GitLab, the CI pipeline runs and it'll update the Shopify Theme online. Similar to Shopify GitHub integration.

 

From a number of days of searching, I've only been able to find a single solution to this:

https://medium.com/@gogl.alex/how-to-deploy-shopify-themes-automatically-1ac17ee1229c

and the community discussion about this:

https://community.shopify.com/c/technical-q-a/development-setup-with-gitlab/m-p/1243584

 

But the problem is this solution is still using the Shopify Theme Kit and not the new Shopify CLI.

 

I would like to ask if someone has already done this in the community and ask if they don't mind sharing the solution in this discussion.

 

Thank you for reading, any advice/s and/or solutions would be very helpful!

Replies 10 (10)

kelem7
Tourist
4 0 1

Hi, I'm currently trying to figure out the same integration and coming up short on helpful tutorials. Were you able to find a solution or a guide that helped you with this? Thank you so much!

CodesDoNotLie
Visitor
3 0 2

Hello! I actually found 2 related discussions that I was planning to try but since I'm on a tight schedule, I wouldn't be able to try applying this at my current project.

Here are the discussions:
https://github.com/Shopify/shopify-cli/issues/1582

https://github.com/Shopify/shopify-cli/issues/2266

 

And it seems there are documentations as well for using Shopify CLI and Continuous Integration, but it's mainly for GitHub and CircleCI:
https://shopify.dev/apps/tools/cli/ci-cd

Maybe you can think of an idea by reading this documentation and make your own workaround and make it work too with GitLab. 

htanipog
Shopify Partner
11 0 2

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
 

 

 

dannycodes
Shopify Partner
5 0 2

I wonder if anyone has run into the following error in Gitlab CI.

 

> shopify app deploy
  ERROR Raw mode is not supported on the current process.stdin, which Ink uses
       as input stream by default.
       Read about how to prevent this error on
       https://github.com/vadimdemedes/ink/#israwmodesupported
 - Read about how to prevent this error on
   https://github.com/vadimdemedes/ink/#israwmodesupported
 - App.handleSetRawMode (node_modules/ink/build/components/App.js:56:27)
 -  (node_modules/ink/build/hooks/use-input.js:38:9)
 -invokePassiveEffect (node_modules/react-reconciler/cjs/react-reconciler.devel
  reate              opment.js:16054:20)
 -Object.invokeGuardedCa (node_modules/react-reconciler/cjs/react-reconciler.de
  lbackProd             velopment.js:12101:10)
 -invokeGuardedCal (node_modules/react-reconciler/cjs/react-reconciler.developm
  back            ent.js:12292:31)
 -flushPassiveEffect (node_modules/react-reconciler/cjs/react-reconciler.develo
  Impl              pment.js:16141:9)
 -unstable_runWithPriori (node_modules/scheduler/cjs/scheduler.development.js:4
  y                     68:12)
 -runWithPriori (node_modules/react-reconciler/cjs/react-reconciler.development
  y            .js:2495:10)
 -flushPassiveEff (node_modules/react-reconciler/cjs/react-reconciler.developme
  cts            nt.js:16014:14)
 -performSyncWorkOn (node_modules/react-reconciler/cjs/react-reconciler.develop
  oot              ment.js:14797:3)

 

In my .gitlab-ci file, I have the steps as per the above answer. And it seems to be running the deploy command but from the looks of the error, it seems like the CLI is trying to use stdin which I guess isn't available within the environment.

 

Does anyone have any ideas?

dannycodes
Shopify Partner
5 0 2

Found the answer. To remove promps just need to add the --force flag to the deploy command

htanipog
Shopify Partner
11 0 2

I still get the same error even after using the --force flag. Where  you able to resolve this? 

athaher
Shopify Partner
1 0 0

Were you able to fix the above error? Because adding force is not working for me.

neilloi
Shopify Partner
1 0 0

I'm getting the same error. Just installed CLI 3.0 on Windows (seemed successful), and the first command I entered (shopify theme init) is returning this raw mode error.

Christopher_He1
Shopify Partner
2 0 0

I get this on a windows box locally when I even try to initialize a new application via: `npm init @Shopify/app@latest`. Same error when I use latest yarn as well.


npm error.png

node --version: 18.14.0
npm --version: 9.6.0
git --version: 2.39.1.windows.1

Christopher_He1
Shopify Partner
2 0 0

It seems like (at least locally anyway) it's a problem with using git bash. If you run it in powershell it runs correctly and you don't get the raw error. I found this documentation: https://blog.logrocket.com/using-stdout-stdin-stderr-node-js/