Created
May 18, 2024 14:20
-
-
Save psahni/173a30a6c499a7ced5f4074269a29822 to your computer and use it in GitHub Desktop.
gitlab_cicd_example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
image: node:10 | |
stages: | |
- build | |
- test | |
- deploy review | |
- deploy staging | |
- deploy production | |
- production tests | |
cache: | |
key: ${CI_COMMIT_REF_SLUG} | |
paths: | |
- node_modules/ | |
variables: | |
STAGING_DOMAIN: instazone-staging.surge.sh | |
PRODUCTION_DOMAIN: instazone.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://instazone-$CI_ENVIRONMENT_SLUG.surge.sh | |
script: | |
- npm install --global surge | |
- surge --project ./public --domain instazone-$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: $PRODUCTION_DOMAIN | |
only: | |
- master | |
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" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
AWS pipeline (Elastic bean stack)