Created
March 8, 2018 19:27
-
-
Save serinth/29fb50a014e8514fa606c1d06ff49829 to your computer and use it in GitHub Desktop.
React gitlab-ci-cd. Tag Based with RC on Test environment Dev/Test/Prod
This file contains hidden or 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:8 | |
stages: | |
- test | |
- build | |
- deploy | |
.deploy_template: &deploy_template | |
before_script: | |
- apt-get update | |
- apt-get install -y python-pip python-dev | |
- pip install awscli | |
script: | |
- aws s3 sync public/ s3://mybucket-${CI_ENVIRONMENT_SLUG}-web/${CI_COMMIT_REF_SLUG} --acl "public-read" | |
- echo "DEPLOY SUCCESSFULLY!!!\n -- https://${CI_COMMIT_REF_SLUG}.web.${CI_ENVIRONMENT_SLUG}.mydomain.com" | |
.build_template: &build_template | |
script: | |
- yarn | |
- yarn run build:${CI_ENVIRONMENT_SLUG} | |
- rm -rf public | |
- mv build public | |
artifacts: | |
paths: | |
- public/ | |
test: | |
stage: test | |
script: | |
- yarn | |
- yarn test || true | |
build:dev: | |
stage: build | |
<<: *build_template | |
environment: | |
name: dev | |
only: | |
- master | |
build:feature-test: | |
stage: build | |
<<: *build_template | |
environment: | |
name: dev | |
only: | |
- branches | |
except: | |
- master | |
build:test: | |
stage: build | |
<<: *build_template | |
environment: | |
name: test | |
only: | |
- /^v\d+\.\d+\.\d+-rc\.\d+$/ | |
except: | |
- triggers | |
- branches | |
build:prod: | |
stage: build | |
<<: *build_template | |
environment: | |
name: prod | |
only: | |
- /^v\d+\.\d+\.\d+$/ | |
except: | |
- triggers | |
when: manual | |
deploy:dev: | |
stage: deploy | |
<<: *deploy_template | |
environment: | |
name: dev | |
only: | |
- master | |
deploy:feature-test: | |
stage: deploy | |
<<: *deploy_template | |
environment: | |
name: dev | |
only: | |
- branches | |
except: | |
- master | |
deploy:test: | |
stage: deploy | |
<<: *deploy_template | |
environment: | |
name: test | |
only: | |
- /^v\d+\.\d+\.\d+-rc\.\d+$/ | |
except: | |
- triggers | |
- branches | |
when: manual | |
deploy:prod: | |
stage: deploy | |
<<: *deploy_template | |
environment: | |
name: prod | |
only: | |
- /^v\d+\.\d+\.\d+$/ | |
except: | |
- triggers | |
when: manual |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment