Update .gitlab-ci.yml

This commit is contained in:
2024-10-14 20:09:17 +00:00
parent 5704326a41
commit b72c6db922
+12 -59
View File
@@ -1,67 +1,20 @@
# Define the stages of the pipeline
stages:
- install
- build
- test
- deploy
# Job to install dependencies
install_dependencies:
stage: install
image: node:20
script:
- npm ci
# Cache für schnellere Builds
cache:
paths:
- node_modules/
# Run automatically on PRs to main
only:
- merge_requests
- main
# Allow manual execution
when: manual
- .next/cache/
# Job to build the Next.js project
build_nextjs:
stage: build
image: node:20
before_script:
- npm ci
pages:
script:
- npm run build
dependencies:
- install_dependencies
cache:
- npm run export # Export für statische Seiten
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:20
script:
- npm test # Replace with your test command (e.g. jest)
dependencies:
- install_dependencies
# 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
# Only run on merge to main branch
only:
- main
# Allow manual execution
when: manual
- out # Das 'out'-Verzeichnis, wenn 'next export' verwendet wird
rules:
- if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH