Create a basic GitLab CI config:
$ cat .gitlab-ci.yml
image: node
before_script:
- npm install
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- node_modules/
- .next/cache/
pages:
script:
- npm run-script build && npm run-script export
- mv out public
artifacts:
paths:
- public
only:
- master
Adapt the assets URL to use the subdirectory of your repo name in the way https://<GITLAB_USER_NAME>.gitlab.com/<GITLAB_PROJECT_NAME>
(removing the brackets <>
):
$ cat next.config.js
# ...
module.exports = {
assetPrefix: process.env.NODE_ENV === 'production' ? '/<GITLAB_PROJECT_NAME>' : '',
# ...
Once we push the changes, GitLab CI will trigger a build and will publish the page under https://<GITLAB_USER_NAME>.gitlab.com/<GITLAB_PROJECT_NAME>
.
When I used the above instruction, my project ran successfully but the public(assets) are not shown in live.
Anyone?
pages:
script:
- npm run-script build && npm run-script export
- rm -rf public/*
- mv out/* public