Deploy Ghost Theme Github Actions CI / Error: Request body larger than maxBodyLength limit

Following this conversation, I want to implement the Github Actions CI for my Ghost theme as well.

Manual steps I do

  • I do gulp build to build my theme.
  • It creates à /dist/ directory.
  • I zip /dist/ manually
  • upload the zip file on Ghost (3.1.1) manually and it’s all good.

So, I’m sure the theme itself is well coded. It passes the gscan test as well.

Error in the CI

But in the CI, the build fails here:

Error: Request body larger than maxBodyLength limit
    at RedirectableRequest.module.exports.549.RedirectableRequest.write (/home/runner/work/_actions/TryGhost/action-deploy-theme/v1.2.0/dist/index.js:7813:24)
    at FormData.ondata (internal/streams/legacy.js:17:31)
    at FormData.emit (events.js:210:5)
    at FormData.module.exports.547.CombinedStream.write (/home/runner/work/_actions/TryGhost/action-deploy-theme/v1.2.0/dist/index.js:7639:8)
    at DelayedStream.ondata (internal/streams/legacy.js:17:31)
    at DelayedStream.emit (events.js:210:5)
    at DelayedStream.module.exports.152.DelayedStream._handleEmit (/home/runner/work/_actions/TryGhost/action-deploy-theme/v1.2.0/dist/index.js:2378:15)
    at ReadStream.source.emit (/home/runner/work/_actions/TryGhost/action-deploy-theme/v1.2.0/dist/index.js:2325:19)
    at addChunk (_stream_readable.js:309:12)
    at readableAddChunk (_stream_readable.js:290:11) {
  isAxiosError: true,
  toJSON: [Function]
}
##[error]Node run failed with exit code 1

This is foreign to me and I don’t understand why I’m getting this error.

Here you can find the RAW logs + the CI.yml I use.

It seems like you’re zipping both your development data and dist data ~ the image referenced in the deploy probably doesn’t have a “build” step

However, there might be an issue in the Admin SDK that borks when payloads > 10 MB exist. I haven’t fully checked, but it looks like the default maxBodyLength value is 10 MB in axios['s dependency], the request lib used by the sdk.

If your dist folder is less than 10MB, everything should be fine

1 Like

If your dist folder is less than 10MB, everything should be fine

  • My /dist folder is big.
  • 49.3MB for 702 items. Many custom pages and images.

I updated the CI.yml + the RAW logs, following your advice to add a step to do the cmd zip -r theme.zip dist/.

On step 6 (the one provided by the ghost team), you are right, the CI does takes everything (and not only my /dist dir).

At this step, what I need is simply a function to push my dist.zip file to my ghost instance.

I totally mis-understood how the action works :grimacing:

As of now, it doesn’t support providing a zip file (there’s a somewhat-related issue).

I’ve made the necessary changes in master of my fork (I haven’t used GA as a publisher so I didn’t realize there’s an additional publishing step involved in making it generally available :upside_down_face:). If you can figure out how to make it work with the uses flag, feel free to :smile:

I looked at your fork and the logic make sens :slight_smile:

I used your fork in my CI but I arrive at the same error:

Full logs.

So at this point, it has the same behavior.

Did you update the config to include file? Just checking :slight_smile:

      - name: 6) Deploy Ghost Theme to our STAGING instance
        uses: TryGhost/action-deploy-theme@v1.2.0
        with:
          api-url: ${{ secrets.GHOST_ADMIN_API_URL }}
          api-key: ${{ secrets.GHOST_ADMIN_API_KEY }}
          file: theme.zip

Testing this right now :-p

EDIT: I update my CI.yml

Humm, the logs are the same. We can see the that CI is compiling the /assets, node_modules, etc.
If you ask me, it does not make sense to see all these files being processed when we specific file: dist.zip

      # https://github.com/TryGhost/action-deploy-theme
      - name: 6) Deploy Ghost Theme to our STAGING instance
        #uses: TryGhost/action-deploy-theme@v1.2.0
        uses: vikaspotluri123/action-deploy-theme@master
        with:
          api-url: ${{ secrets.GHOST_ADMIN_API_URL }}
          api-key: ${{ secrets.GHOST_ADMIN_API_KEY }}
          file: dist.zip
          # absolute path: /home/runner/work/containous.website/containous.website/dist.zip

A precision about:

Humm, the logs are the same.

The CI does recompile everything and gets to the same error “Error: Request body larger than maxBodyLength limit”.

Here is my logic. The flag “file: dist.zip” should simply bypass all that jazz and upload the dist.zip file right?

Thanks!

@pascalandy I replied to you on Github about this, the error is coming from the axios library that @tryghost/admin-api uses. I’ve opened an issue here https://github.com/TryGhost/Ghost-SDK/issues/195

1 Like

Hmm, did you also update the log file? If you did, it looks like the var wasn’t passed

I agree this message *** is cryptic.
Is it hashed? (which is OK)
Is it missing ?

2020-01-07T22:29:16.9662464Z   api-url: ***
2020-01-07T22:29:16.9662610Z   api-key: ***

To test my secret, I removed the var GHOST_ADMIN_API_URL from my Github Secret. As expected, the CI complains:

Error: GhostAdminAPI Config Missing: @tryghost/admin-api requires a "url" like "https://site.com" or "https://site.com/blog"

To me, the system does not complain about these:

2020-01-07T22:29:16.9662464Z   api-url: ***
2020-01-07T22:29:16.9662610Z   api-key: ***

I’ve updated the action. Turns out there was a build step. Can you rerun CI?

Just did. We got a new error.

I think there is a typo here:

zipPath = path.join(basePath, themeZip);

themeZip should be a variable.

logs

Let me know if you need the raw logs. (they are so big it makes my browser lag lol)

CI.ylml

gist

pushed

Alright! The file dist.zip seems to be considered this time! The theme is not recompiling :slight_smile:

We are stock with the original bug but at least we are closer :slight_smile:

Run vikaspotluri123/action-deploy-theme@master
  with:
    api-url: ***
    api-key: ***
    file: dist.zip
Error: Request body larger than maxBodyLength limit
    at RedirectableRequest.module.exports.549.RedirectableRequest.write (/home/runner/work/_actions/vikaspotluri123/action-deploy-theme/master/dist/index.js:7821:24)
    at FormData.ondata (internal/streams/legacy.js:17:31)
    at FormData.emit (events.js:210:5)
    at FormData.module.exports.547.CombinedStream.write (/home/runner/work/_actions/vikaspotluri123/action-deploy-theme/master/dist/index.js:7647:8)
    at DelayedStream.ondata (internal/streams/legacy.js:17:31)
    at DelayedStream.emit (events.js:210:5)
    at DelayedStream.module.exports.152.DelayedStream._handleEmit (/home/runner/work/_actions/vikaspotluri123/action-deploy-theme/master/dist/index.js:2386:15)
    at ReadStream.source.emit (/home/runner/work/_actions/vikaspotluri123/action-deploy-theme/master/dist/index.js:2333:19)
    at addChunk (_stream_readable.js:309:12)
    at readableAddChunk (_stream_readable.js:290:11) {
  isAxiosError: true,
  toJSON: [Function]
}

This masking is necessary to avoid private secrets that give complete admin access to your site leaking through log files or being shared such as what you’ve been doing here :wink: Secret masking is a standard security practice and is done automatically by GitHub when it creates workflow logs.

Thanks for confirming Kevin!

@pascalandy the bug in @tryghost/admin-api causing the maxBodyLength error is fixed now.

You may need to update the dependency in any lock files if you’re using them, otherwise I think you should be good to go :slight_smile:

1 Like