Shopify / cli

Build apps, themes, and hydrogen storefronts for Shopify
https://shopify.dev
MIT License
425 stars 127 forks source link

[Bug]: CLI fails deploy to live theme on github action. (Shopify theme push) 3.6.9 #4708

Closed Visylvius closed 1 hour ago

Visylvius commented 1 day ago

Please confirm that you have:

In which of these areas are you experiencing a problem?

Other, Theme

Expected behavior

Hey Folks.

So our github action just stopped working today as you can see below. Image

The confusing bit is, we have added the following configurations to the CLI file.

name: Production | Deployment | Pull new JSON from Live -> Build -> Deploy Production

on:
  push:
    branches: ['main']
  workflow_dispatch:

jobs:
  build-and-deploy:
    name: Build and Deploy Production Theme
    if: ${{ !contains(github.event.head_commit.message, 'Update from Shopify') }}
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4.1.7

      - uses: actions/setup-node@v4.0.3
        with:
          node-version: 20.16.0

      - uses: ruby/setup-ruby@v1.190.0
        with:
          ruby-version: 3.3.0
          bundler: 'latest'

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

      - name: Install Dependencies
        run: npm i

      - name: Pull JSON files from live theme
        env:
          SHOPIFY_FLAG_STORE: '${{ secrets.SHOPIFY_STORE }}'
          SHOPIFY_CLI_THEME_TOKEN: ${{ secrets.SHOPIFY_CLI_THEME_TOKEN }}
          SHOPIFY_CLI_TTY: 0
          SHOPIFY_FLAG_FORCE: 1
        run: |
          # Create a temporary directory for JSON files
          mkdir temp_json
          # Pull all JSON files to the temporary directory
          shopify theme pull --theme=MY_THEME_ID_HERE --only '*.json' --path temp_json
          # Compare and copy newer files
          for file in temp_json/**/*.json; do
            rel_path=${file#temp_json/}
            if [ ! -f "$rel_path" ] || [ "$file" -nt "$rel_path" ]; then
              mkdir -p $(dirname "$rel_path")
              cp "$file" "$rel_path"
              echo "Updated: $rel_path"
            fi
          done
          # Clean up
          rm -rf temp_json
      - name: Build and Package Theme Files
        run: |
          export NODE_OPTIONS=--max_old_space_size=4096
          npm run build
      - name: Deploy to Production Theme
        env:
          SHOPIFY_FLAG_STORE: '${{ secrets.SHOPIFY_STORE }}'
          SHOPIFY_CLI_THEME_TOKEN: ${{ secrets.SHOPIFY_CLI_THEME_TOKEN }}
          SHOPIFY_CLI_TTY: 0
          SHOPIFY_FLAG_FORCE: 1
        run: shopify theme push -a --theme MY_THEME_ID_HERE

We've added the FLAG_FORCE, since that wasn't there before. But it's somewhat confusing as to why the interactive portion is causing it to fail, when it was working 3 days ago.

Actual behavior

It should properly push or theme into our live theme.

Verbose output

Run echo "Shopify CLI version:"
  echo "Shopify CLI version:"
  shopify version
  echo "Attempting to push theme:"
  shopify theme push -a --theme MY_THEME_ID_HERE --verbose
  shell: /usr/bin/bash -e {0}
  env:
    SHOPIFY_FLAG_STORE: ***
    SHOPIFY_CLI_THEME_TOKEN: ***
    SHOPIFY_CLI_TTY: 0
    SHOPIFY_FLAG_FORCE: 1
Shopify CLI version:
3.69.0
Attempting to push theme:
2024-10-21T21:06:33.783Z: Running command theme push
2024-10-21T21:06:33.792Z: Ensuring that the user is authenticated with the Theme API with the following scopes:
[]
2024-10-21T21:06:34.211Z: Request to https://theme-kit-access.shopifyapps.com/cli/admin/api/unstable/themes.json?fields=id%2Cname%2Crole%2Cprocessing completed in 411 ms
With response headers:
 - cache-control: max-age=0, private, must-revalidate
 - content-type: application/json; charset=utf-8
 - etag: W/"eec0b5bb789b3d4c500de45c9666ebcd"
 - server-timing: processing;dur=231, socket_queue;dur=7.312, cfRequestDuration;dur=317.999840
 - x-request-id: ff336899-f4da-4479-aec3-854cb99f3af5-1729544793

╭─ error ──────────────────────────────────────────────────────────────────────╮
│                                                                              │
│  Failed to prompt:                                                           │
│                                                                              │
│  Push theme files to the live theme on hairstorystudio.myshopify.com?        │
│                                                                              │
│  This usually happens when running a command non-interactively, for example  │
│   in a CI environment, or when piping to or from another process.            │
│                                                                              │
│  To resolve this, specify the option in the command, or run the command in   │
│  an interactive environment such as your local terminal.                     │
│                                                                              │
╰──────────────────────────────────────────────────────────────────────────────╯
2024-10-21T21:06:34.259Z: 
Running system process:
  · Command: npm prefix
  · Working directory: /home/runner/work/US-hairstory-2.0/US-hairstory-2.0
2024-10-21T21:06:34.357Z: Obtaining the dependency manager in directory /home/runner/work/US-hairstory-2.0/US-hairstory-2.0...
2024-10-21T21:06:34.459Z: 
Running system process:
  · Command: ruby -v
  · Working directory: /home/runner/work/US-hairstory-2.0/US-hairstory-2.0
2024-10-21T21:06:34.603Z: Request to https://monorail-edge.shopifysvc.com/v1/produce completed in 122 ms
With response headers:
 - x-request-id: c9db6861-5dc9-44a6-a4d3-adc6f590b30d

2024-10-21T21:06:34.604Z: Analytics event sent: {
  "command": "theme push",
  "time_start": 1729544793785,
  "time_end": 1729544794252,
  "total_time": 467,
  "success": false,
  "cli_version": "3.69.0",
  "ruby_version": "3.3.0",
  "node_version": "20.16.0",
  "is_employee": false,
  "uname": "linux amd64",
  "env_ci": true,
  "env_ci_platform": "github",
  "env_plugin_installed_any_custom": false,
  "env_plugin_installed_shopify": "[\"@shopify/cli\"]",
  "env_shell": "bash",
  "env_device_id": "887dc61bb5aa726f9f0e293456ba41ff1ddae213",
  "env_cloud": "localhost",
  "env_package_manager": "npm",
  "env_is_global": true,
  "env_auth_method": "theme_access_token",
  "cmd_app_warning_api_key_deprecation_displayed": false,
  "cmd_all_timing_network_ms": 411,
  "cmd_all_timing_prompts_ms": 0,
  "cmd_all_launcher": "unknown",
  "cmd_all_topic": "theme",
  "cmd_all_plugin": "@shopify/theme",
  "cmd_all_force": false,
  "cmd_all_verbose": true,
  "cmd_all_path_override": true,
  "cmd_all_path_override_hash": "fda198f16606d1a11a8ae8c72ed73e645dfd37b1",
  "cmd_all_timing_active_ms": 55,
  "cmd_all_exit": "expected_error",
  "user_id": "5fe438e1-48df-4e04-47dd-f339d00965c45ed0e748",
  "args": "-a --theme 143661629670 --verbose",
  "error_message": "Failed to prompt:\n\nPush theme files to the live theme on hairstorystudio.myshopify.com?\n\nThis usually happens when running a command non-interactively, for example in a CI environment, or when piping to or from another process.",
  "env_plugin_installed_all": "[\"@shopify/cli\"]",
  "metadata": "{\"extraPublic\":{},\"extraSensitive\":{}}"
}
2024-10-21T21:06:34.624Z: Reporting handled error to Bugsnag: Failed to prompt:
Push theme files to the live theme on hairstorystudio.myshopify.com?
This usually happens when running a command non-interactively, for example in a CI environment, or when piping to or from another process.
2024-10-21T21:06:35.044Z: 
Running system process:
  · Command: npm prefix
  · Working directory: /home/runner/work/US-hairstory-2.0/US-hairstory-2.0
2024-10-21T21:06:35.141Z: Obtaining the dependency manager in directory /home/runner/work/US-hairstory-2.0/US-hairstory-2.0...

Reproduction steps

  1. Run the github action pointed at a live theme
  2. Make sure the -a command is present run: shopify theme push -a --theme MY_THEME_ID_HERE
  3. During that step of the github action, the build will fail.

Operating System

Git

Shopify CLI version (check your project's package.json if you're not sure)

We're downloading it through npm

Shell

No response

Node version (run node -v if you're not sure)

No response

What language and version are you using in your application?

No response

akillmer commented 1 day ago

Started experiencing this issue with GitHub actions, too.

andy-hanasoft commented 1 day ago

Started getting this issue on bitbucket pipeline this morning too!

ColinPeyrat commented 1 day ago

Hi, I just got this same issue, it's related to this issue

I didn't found any other fixes that rollback to 3.68.0

In your package.json :

"devDependencies": {
  "@shopify/cli": "3.68.0",
}
fxchain commented 1 day ago

I fixed this by downgrading Shopify CLI in my .yml action file :

run: npm install -g @shopify/cli@3.66.1 @shopify/theme

Visylvius commented 1 day ago

Same. I reverted to the last stable version, and the build started working again. Which confirms that the latest change from 3.69.0 stopped the CLI flag from working.

jamesmengo commented 1 day ago

Hey everyone! Thanks for reporting this. A fix for this is under review - https://github.com/Shopify/cli/pull/4716

In the meantime, feel free to either:

Visylvius commented 23 hours ago

Thanks for responding so quickly!