Gitlab pages pipeline is passing but site is not loading

I’m trying to deploy this template on Gitlab:

I am not sure if my gitlab-ci.yml file is wrong:

It doesnt seem to work even though pipeline passes:

If my gitlab-ci.yml file is incorrect please let me know which template I should be using. Currently it is plain HTML. Also if there is somewhere I should be looking in the documentation please send me link.
Thank you!

Your .gitlab-ci is only building a docker Image, you need to use a template with a pages job to publish on You can start from here:

If you look here you can see that I tried using various templates with no success:

The original project uses npm and nodejs. so I tried those templates as well.

You need to do different things: first, you need to install your dependencies and build your website. Then, you need to move the result of the build in a directory named public. Also, the job should be named pages.

I haven’t looked at your code, so I don’t know if it works, but a good starting point should be:

image: node:latest

    - node_modules/

  stage: deploy
  - npm install
  - npm build
  - mv dist/ public/
    - public
  - master

Thank you for the advice. I am using the npm template and getting this error “Invalid package scope! Packages must be scoped in the root namespace of the project”

It may not be my .gitlab-ci.yml file but rather the package.json file that I wrote incorrectly. Is the scope set in packages.json after `“name”: ?
Also it seems this file has “predeploy”: “npm run build”, which may make - npm instal - npm build in the .gitlab-ci.yml file redundant. Your help is greatly appreciated!

This is because you have a job that validate the name of the package:

# Validate that the package name is properly scoped to the project's root namespace.
# For more information, see
  stage: build
    - |
      if [[ ! $NPM_PACKAGE_NAME =~ ^@$CI_PROJECT_ROOT_NAMESPACE/ ]]; then
        echo "Invalid package scope! Packages must be scoped in the root namespace of the project, e.g. \"@${CI_PROJECT_ROOT_NAMESPACE}/${CI_PROJECT_NAME}\""
        echo 'For more information, see'
        exit 1

There is a link to the documentation, up to you choosing if this is something that interestes you or not. If not, you can simply remove the job.

Where are the packages in my repository that this is referring to?

Ok so I removed that, I am still not sure exactly what packages it is referring to. But now i get error “npm ERR! 404 You should bug the author to publish it (or use the name yourself!)”

It may be because I am not setting "name": properly in package.json. I also change private from true to false as that was throwing an error. It seemed to resolve the error but I don’t know if that is supposed to be changed.

You don’t actually want to publish a npm package, so you don’t need all these jobs.

I suggest starting from scratch with the example I provided you. After having that working, you can add other jobs as well, understanding what they do.

I get error ‘mv: cannot stat ‘dist/’: No such file or directory’

So I tried using ’ mv /builds/agronick98/portfolio/.git public/’ since thats where the script seems to build and it passes but the site is not working

Actually, the problem is with npm build. You can see it from the output of the job:

So you need to change the npm build with npm run-script build, and then the output of your website will be in build/, so the last step has to be mv public .public && mv build public

Ok I did see that and it seems to throw the same error even if I add ‘mv public .public && mv build public’ but it just says “Failed to compile.”

https://gitlab (.) com/agronick98/portfolio/-/pipelines/193664135

It explains that all the warnings in the code are now treated as errors since you are using CI:

Treating warnings as errors because process.env.CI = true. Most CI servers set it automatically.

You should fix all the warnings, then it will work :slight_smile:

Awesome, I got it running by doing CI=false npm run-script build. Some of these warning are not important, like unused optional dependency. However some of these are more concerning but I am unsure of how to fix them.

How do I resolve npm WARN @apollo/react-common@3.1.4 requires a peer of @types/react@^16.8.0 but none is installed. You must install peer dependencies yourself. I assume I need to add something for react@^16.8.0 in package.json dependencies.

Thank you!