When creating a new GitLab project, GitLab allows you to start with a template instead of a blank project.
One of the templates is is the Pages/Plain HTML
This template uses a minimal CI workflow that does nothing.
All files in the public directory of the project will end up in the root of the web page.
For your use case, you just need to put your web page files (like index.html) into the public directory and run the CI pipeline once.
If your repository is on gitlab.com, one of the public runners can be used with your project without setting up any custom runners.
For more details, see the Create a GitLab Pages website from a project template documentation.
To view the logs of a GitLab Pipeline/Jobs go to Build -> Jobs
and click the latest Job with a red X symbol and Failed text.
The problem in your CI script is:
Answer from Peter on Stack Overflow$ cp index.html public/
cp: cannot create regular file 'public/': Not a directory
git - Can I render HTML on GitLab? - Stack Overflow
git tag - Serve static html pages with Gitlab Pages for each tagged version of a project - Stack Overflow
git - Host static website with GitLab pages - Stack Overflow
How can I view artifacts ( html page, .txt fiile etc., ) in GitLab?
First of all, Git and products like GitLab and GitHub are different things. Git doesn't ever render anything; it's a version control system. It doesn't have a web interface.
Secondly, GitLab's core product isn't supposed to render anything. It's not a web host, it's a tool for hosting, sharing, and managing Git repositories. However you might want to try GitLab Pages:
GitLab Pages is a feature that allows you to publish static websites directly from a repository in GitLab.
You can use it either for personal or business websites, such as portfolios, documentation, manifestos, and business presentations. You can also attribute any license to your content.
Pages is available for free for all GitLab.com users as well as for self-managed instances (GitLab Core, Starter, Premium, and Ultimate).
GitLab Pages will publish content from the public/ directory of your repository, so you should move your files there. You will also need a .gitlab-ci.yml file in the root of your repository containing something like
image: alpine:latest
pages:
stage: deploy
script:
- echo 'Nothing to do...'
artifacts:
paths:
- public
only:
- master
(taken from the sample repository). Add that file, then commit and push. After deployment is complete, your site should be available at https://youruser.gitlab.io/yourproject.
Note that GitHub has a similar product (that works differently).
Finally,
I looked at other projects' repositories, such as
pandas,sphinx. They only have.rtsfiles in the repository, and not HTML files. I guess they generate HTML for their websites but don't upload to Git.
it's very likely that the reStructured Text files are the only source that exists, and that HTML is generated from them automatically. Sphinx this format by default. If you're interested in working from another format like Markdown or reStructured Text you may want to explore GitLab Pages' support for static site generators.
Another solution:
At the root of your repo, add a file called .gitlab-ci.yml containing the following lines:
pages:
script:
- mkdir .public
- cp -r * .public
- mv .public public
artifacts:
paths:
- public
Your file should then be available at
https://your-username.gitlab.io/project-name/filename.html
See this post for details: Gitlab: host and render HTML files