Skip to content

Commit

Permalink
page(gl-pages): use newer .gitlab-ci.yml syntax (hexojs#1785)
Browse files Browse the repository at this point in the history
* page(gl-pages): use newer .gitlab-ci.yml syntax

- update image to nodejs 16
- update links to gitlab docs

* page(gl-pages): fix numbering
  • Loading branch information
curbengh authored Mar 29, 2022
1 parent 5b43665 commit 749287b
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions source/docs/gitlab-pages.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ title: GitLab Pages
---

1. Create a new repository named <b>*username*.gitlab.io</b>, where username is your username on GitLab. If you have already uploaded to other repo, rename the repo instead.
2. Enable Shared Runners via `Settings -> CI / CD -> Shared Runners`.
2. Enable Shared Runners via **Settings** > **CI/CD** > **Runners** > **Enable shared runners for this project**.
3. Push the files of your Hexo folder to the repository. The `public/` folder is not (and should not be) uploaded by default, make sure the `.gitignore` file contains `public/` line. The folder structure should be roughly similar to [this repo](https://gitlab.com/pages/hexo).
4. Add `.gitlab-ci.yml` file to your repo (alongside _config.yml & package.json) with the following content:
4. Check what version of Node.js you are using on your local machine with `node --version`. Make a note of the major version (e.g., `v16.y.z`)
5. Add `.gitlab-ci.yml` file to the root folder of your repo (alongside _config.yml & package.json) with the following content (replacing `16` with the major version of Node.js you noted in previous step):

``` yml
image: node:14-alpine # use nodejs v14 LTS
image: node:16-alpine
cache:
paths:
- node_modules/
Expand All @@ -19,26 +20,26 @@ before_script:

pages:
script:
- hexo generate
- npm run build
artifacts:
paths:
- public
only:
- master
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
```
5. *username*.gitlab.io should be up and running, once GitLab CI finishes the deployment job,
6. (Optional) If you wish to inspect the generated site assets (html, css, js, etc), they can be found in the [job artifact](https://docs.gitlab.com/ee/user/project/pipelines/job_artifacts.html).
6. *username*.gitlab.io should be up and running, once GitLab CI finishes the deployment job,
7. (Optional) If you wish to inspect the generated site assets (html, css, js, etc), they can be found in the [job artifact](https://docs.gitlab.com/ee/ci/pipelines/job_artifacts.html).
## Project page
If you prefer to have a project page on GitLab:
1. Go to `Settings -> General -> Advanced -> Change path`. Change the value to a name, so the website is available at <b>username.gitlab.io/*name*</b>. It can be any name, like *blog* or *hexo*.
2. Edit **_config.yml**, change the `root:` value from `""` to `"name"`.
1. Go to **Settings** > **General** > **Advanced** > **Change path**. Change the value to a name, so the website is available at <b>username.gitlab.io/*repository*</b>. It can be any name, like *blog* or *hexo*.
2. Edit **_config.yml**, change the `url:` value to `https://username.gitlab.io/repository`.
3. Commit and push.

## Useful links

- [GitLab Pages](https://docs.gitlab.com/ee/user/project/pages/index.html)
- [GitLab CI Docs](https://docs.gitlab.com/ee/ci/README.html)
- [GitLab Pages](https://docs.gitlab.com/ee/user/project/pages/)
- [GitLab CI Docs](https://docs.gitlab.com/ee/ci/yaml/)

0 comments on commit 749287b

Please sign in to comment.