Skip to content

Instantly share code, notes, and snippets.

@ariona
Last active August 8, 2022 01:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ariona/ad173ea6763d5e069d60b37242f299a3 to your computer and use it in GitHub Desktop.
Save ariona/ad173ea6763d5e069d60b37242f299a3 to your computer and use it in GitHub Desktop.
Deploying Next.js App to GitLab pages
image: node
before_script:
- npm install --force
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- node_modules/
- .next/cache/
pages:
script:
- npm run-script build && npm run-script export
- cp -r out/* public
artifacts:
paths:
- public
only:
- master

Since gitlab use public folder for storing public assets, we only need to move exported script/files from out directory to public directory by executing

cp -r out/* public

Note that exported next.js project not supporting params url (dynamic url), so we must convert it to query based param (?param=value)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment