when deploying using gitlab ci you have tasks defined in stages.

Make sure to use container that hopefully already has all tools you need.

once you cd into a directory… your there for the rest of the steps.

#.gitlab-ci.yml
stages:
  - deploy_step

deploy_step:
  image: node:latest

  stage: deploy
  environment:
    THE_VAL: green
  only:
    - master
  script:
    - npm -v
    - cd template-master && npm i
    # your in template master now...
    - npm run build
    - echo "hi"
    - echo `pwd` 
    - npm install netlify-cli -g
    - netlify deploy --dir public --site $NETLIFY_SITE_ID --auth $NETLIFY_AUTH_TOKEN --prod