diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..37ddf6b --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,80 @@ +# Define the stages of the pipeline +stages: + - install + - build + - test + - deploy + +# Job to install dependencies +install_dependencies: + stage: install + image: node:16 + script: + - npm ci + cache: + paths: + - node_modules/ + artifacts: + paths: + - node_modules/ + # Run automatically on PRs to main + only: + - merge_requests + - main + # Allow manual execution + when: manual + +# Job to build the Next.js project +build_nextjs: + stage: build + image: node:16 + script: + - npm run build + dependencies: + - install_dependencies + cache: + paths: + - .next/ + artifacts: + paths: + - .next/ + # Run automatically on PRs to main + only: + - merge_requests + - main + # Allow manual execution + when: manual + +# Job to run tests +run_tests: + stage: test + image: node:16 + script: + - npm test # Replace with your test command (e.g. jest) + dependencies: + - install_dependencies + artifacts: + when: always + paths: + - test-reports/ + # Run automatically on PRs to main + only: + - merge_requests + - main + # Allow manual execution + when: manual + +# Deploy step (runs only on merge to main) +deploy: + stage: deploy + script: + - mkdir public + - cp -r .next/* public # Example for GitLab Pages, adjust as needed + artifacts: + paths: + - public + # Only run on merge to main branch + only: + - main + # Allow manual execution + when: manual