Home > Software design >  Github action zip doesn't find the files on self hosted worker
Github action zip doesn't find the files on self hosted worker

Time:07-19

I've been trying to archive files after compilation matching the wildcard **/dist when I look into my _work folder of my GitHub action worker, I see the files and if I run the zip command from shell, it works fine, but in action, it throws an error saying it can't find any files matching

zip error: Nothing to do! (try: zip -qq -r archive.zip . -i **/dist)

Yet when I run directly in the runner ls -la **/dist I get a list of over 200 files

I was also able to reproduce the issue by adding the command inside my package.json then when I run yarn archive I get the same issue as GitHub action

 "archive": "pwd && ls -la **/dist && zip -r **/dist",

Output of yarn archive

yarn run v1.22.19
$ pwd && ls -la **/dist && zip -r **/dist
/home/mathieu_auclair/actions-runner/_work/server/server
ls: cannot access '**/dist': No such file or directory
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

CodePudding user response:

It is about how the shell will interpret the wildcards used.

I would try and put the set of commands ls -la **/dist && zip -r **/dist in a bash executable script starting with #!/bin/bash, and call said script instead of chaining commands with '**'.

The OP MathieuAuclair confirms in the comments:

Indeed, I was able to fix it by making the zip command specification more detailed, I guess it's compatible between both interpretations

zip -r archive.zip . --include **/dist/**
  • Related