like staging, production, added different environments below.
And can refer values using variables.
We can use only keyword to specify branch name
stages:
- build
- test
#global cache for all jobs
#cache:
# key: ${CI_COMMIT_REF_SLUG}
# paths:
# - node_modules/
variables:
STAGING_DOMAIN: instazone-staging.surge.sh
PRODUCTION_DOMAIN: instazone-production.surge.sh
build-websites:
stage: build
image: node
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- node_modules/
script:
- npm install
- npm install -g gatsby-cli
- gatsby build
artifacts:
paths:
- ./public
test artifact:
image: alpine
stage: test
script:
- grep -q "Gatsby" ./public/index.html
- grep "XXXXX" ./public/index.html
test artifact:
image: alpine
stage: test
script:
- npm install
- npm insrall -g gatsby-cli
- gatsby serve & # & is for background job
- sleep 3
- curl "http://localhost:9000" | tac | tac | grep -q "Gatsby"
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://$STAGING_PRODUCTION
when: manual
allow_failure: false #this will block remaining steps to execute till this manual stage is ran
script:
- npm install --global surge
- surge --project ./public --domain $STAGING_PRODUCTION
No comments:
Post a Comment