반응형
## Deploy Review Job 추가 생성
- Branch 에서 소스변경 (feature/oky)
- Master 로 Merge Requests 클릭
## .gitlab-ci.yml
image: node
stages:
- build
- test
- deploy review
- deploy staging
- deploy production
- production tests
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- node_modules/
variables:
STAGING_DOMAIN: aido-stg.surge.sh
PRODUCTION_DOMAIN: aido-pro.surge.sh
build website:
stage: build
only:
- master
- merge_requests
script:
- echo $CI_COMMIT_SHORT_SHA
- npm install
- npm install -g gatsby-cli
- gatsby build
- sed -i "s/%%VERSION%%/$CI_COMMIT_SHORT_SHA/" ./public/index.html
artifacts:
paths:
- ./public
test artifact:
image: alpine
stage: test
only:
- master
- merge_requests
script:
- grep -q "Gatsby" ./public/index.html
test website:
stage: test
only:
- master
- merge_requests
script:
- npm install
- npm install -g gatsby-cli
- gatsby serve &
- sleep 3
- curl "http://localhost:9000" | tac | tac | grep -q "Gatsby"
deploy review:
stage: deploy review
only:
- merge_requests
environment:
name: review/$CI_COMMIT_REF_NAME
url: https://aido-$CI_ENVIRONMENT_SLUG.surge.sh
script:
- npm install --global surge
- surge --project ./public --domain aido-$CI_ENVIRONMENT_SLUG.surge.sh
deploy staging:
stage: deploy staging
environment:
name: staging
url: http://$STAGING_DOMAIN
only:
- master
script:
- npm install --global surge
- surge --project ./public --domain $STAGING_DOMAIN
deploy production:
stage: deploy production
environment:
name: production
url: http://$PRODUCTION_DOMAIN
only:
- master
# when: manual
# allow_failure: false
script:
- npm install --global surge
- surge --project ./public --domain $PRODUCTION_DOMAIN
production tests:
image: alpine
stage: production tests
only:
- master
script:
- apk add --no-cache curl
- curl -s "https://$PRODUCTION_DOMAIN" | grep -q "Hi people"
- curl -s "https://$PRODUCTION_DOMAIN" | grep -q "$CI_COMMIT_SHORT_SHA"
======================================
반응형
'[AWS] > GITLAB' 카테고리의 다른 글
39장. Destroying environments (Clean-up after the Merge Request) (0) | 2022.02.21 |
---|---|
38장. 사용할 수 없는 환경 변수 문제 해결 (0) | 2022.02.20 |
36장. 병합 요청 - 첫 번째 병합 요청 (0) | 2022.02.18 |
35장. Merge requests - Configuring Gitlab (0) | 2022.02.18 |
33장. Merge requests - Using branches (0) | 2022.02.18 |
댓글