How to run docker image in GitHub action with npm command

I am trying to run a docker container in github action with npm command.

  - name: Run docker container
      BRANCH_TAG: ${{needs.test.outputs.BRANCH}}
      ENV: ${{needs.test.outputs.ENV}}
    run: |
      docker run -it -e ENV=$ENV \$BRANCH_TAG \
        -- sh -c "npm run app:test:quest"

When I run docker run command with -it . I get the input device is not a TTY error.

When I use -i or without -i . I am getting this error tail: invalid number of bytes: 'npm run cy:test:parallel:github'

and if I use -d then I am not getting any logs generating from the npm command. How to run docker container which will show the npm logs as well?

Are you trying to run a service (to be used later) or a one-off command? For the latter you shouldn’t need either of the options. For the former you need -d and can then access the output with docker logs.

This combined with the error message from tail looks like the command might be somewhat broken, but it’s hard to say how to fix it without knowing what exactly should run and what the ENTRYPOINT of the image looks like.