GitLab Pages, Packages & Interview Questions
GitLab Pages
Deploy static websites directly from a GitLab project using CI/CD. Free for all plans on gitlab.com.
# .gitlab-ci.yml for a static site (e.g., Hugo, Jekyll, plain HTML)
pages:
stage: deploy
script:
- apt-get install -y hugo
- hugo --minify
artifacts:
paths:
- public # must be named "public"
rules:
- if: '$CI_COMMIT_BRANCH == "main"'Published at: https://<namespace>.gitlab.io/<project> (or custom domain)
Custom domain: Settings → Pages → Add domain + DNS CNAME
HTTPS: auto-provisioned via Let's Encrypt
Access control: restrict Pages to authenticated GitLab members (Ultimate)
Redirect rules: _redirects file (Netlify-compatible format)
Package Registry
GitLab Package Registry supports npm, PyPI, Maven, Go modules, Composer, Conan, Helm charts, and more — all hosted inside your project or group.
# Publish npm package to GitLab registry
# .npmrc
@mygroup:registry=https://gitlab.com/api/v4/packages/npm/
//gitlab.com/api/v4/packages/npm/:_authToken=${CI_JOB_TOKEN}
# Publish in CI
npm publish --registry https://gitlab.com/api/v4/projects/${CI_PROJECT_ID}/packages/npm/
# Publish PyPI package
pip install twine
twine upload --repository-url ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/pypi dist/*GitLab CLI (glab)
# Install: brew install glab
glab auth login
# Repos
glab repo clone group/project
glab repo create
# MRs
glab mr create
glab mr list --state=opened
glab mr checkout 42
glab mr approve 42
glab mr merge 42 --squash
# Issues
glab issue create --title "..." --label bug
glab issue list
glab issue close 42
# Pipelines
glab pipeline list
glab pipeline status
glab pipeline retry 99
glab ci view # TUI pipeline viewerGitLab vs GitHub — Key Differences
CI/CD: GitLab CI is built-in and more configurable; GitHub Actions requires YAML workflows but has larger marketplace
Merge Requests vs Pull Requests: functionally identical, different name
Self-managed: GitLab has a robust CE/EE self-hosted option; GitHub has GitHub Enterprise Server
Security: GitLab bundles SAST, DAST, dependency scanning at Ultimate; GitHub Advanced Security is add-on
Pipelines: GitLab has DAG pipelines (needs:), parent-child, merge trains natively; GitHub Actions has matrix but no native DAG
Package registry: both have one; GitLab supports more package formats natively
Project management: GitLab has epics, roadmaps, iterations built in; GitHub has Projects (kanban) + Milestones
Interview Questions
What is a merge train and when would you use one? — Queue of MRs tested together before merging, prevents broken builds on main
How do you prevent a secret from leaking in CI logs? — Use masked CI variables; never echo secrets; use file-type variables for certs
Difference between cache and artifacts in GitLab CI? — Cache speeds up jobs (node_modules); Artifacts pass files between jobs or download after pipeline
How would you implement branch-based environment deployments? — Dynamic environments with review apps, stop action on MR close
What is a protected branch vs protected environment? — Branch: controls who can push/merge; Environment: controls who can deploy there
How do you handle database migrations in GitLab CI? — Separate migration job in deploy stage, run before main app deploy, rollback strategy
What is the difference between only/except and rules? — rules is more flexible, supports complex conditions (if/when/changes/exists); only/except is older and simpler
How would you structure a monorepo CI pipeline? — parent-child pipelines with trigger: include, use changes: to only run affected child pipelines
Keep your own version of these notes — editable, searchable, and organised by your stack.
Start free