It should be the same as using any other build tool. As long as the command is executed in the directory of the next.js app, it should build okay. Is there anything in particular that you were wondering about?
If you want to deploy the build inside your workflow instead of through the pages git integration, you can use Wrangler. So, you would run the following two commands:
The first of those two commands builds your nextjs app, the second one deploys it. I don't use Gitlab so I'm afraid I can't help with the workflow file's syntax.
I would recommend using the Pages Git integration, it will be much simpler. If you do want to use your own github action, check out https://github.com/cloudflare/pages-action