Skip to content

Instantly share code, notes, and snippets.

@des1roer
Last active October 31, 2022 07:20
Show Gist options
  • Save des1roer/a757c49e1f79e0719499381a54bf234c to your computer and use it in GitHub Desktop.
Save des1roer/a757c49e1f79e0719499381a54bf234c to your computer and use it in GitHub Desktop.
stages:
- build
- test
- review
- deploy
vendor_update:
stage: build
only:
- schedules
- web
- triggers
- merge_requests
script:
- composer install --prefer-dist
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- vendor/
# codecept_encoded:
# stage: test
# parallel: 5
# only:
# - schedules
# - web
# - triggers
# - merge_requests
# before_script:
# - export RUN_CONCURENT_ID=$(expr $CI_CONCURRENT_ID + 1)
# - php init.php --silent=y --overwrite=y --env=Development --db_name=test_gitlab$RUN_CONCURENT_ID --db_user=$TEST_DB_USER --db_password=$TEST_DB_PASSWORD
# - php yii migrate up --interactive=0 > /dev/null
# script:
# - vendor/bin/robo parallel:split-tests $CI_NODE_TOTAL
# - vendor/bin/codecept -vvv run unit --group paracept_$RUN_CONCURENT_ID --xml report.xml
# after_script:
# - php yii migrate/down all --interactive=0 > /dev/null
# cache:
# key: ${CI_COMMIT_REF_SLUG}
# policy: pull
# paths:
# - vendor/
# artifacts:
# paths:
# - backend/tests/_output/
# reports:
# junit:
# - backend/tests/_output/report.xml
# expire_in: 1 days
phpcs:
stage: test
only:
- schedules
- web
- triggers
- merge_requests
script:
- bash .gitlab/ci/run_phpcs.sh
cache:
key: ${CI_COMMIT_REF_SLUG}
policy: pull
paths:
- vendor/
artifacts:
paths:
- gl-code-quality-report.json
reports:
codequality: gl-code-quality-report.json
expire_in: 15 min
bd-test1:
stage: review
only:
- web
- merge_requests
script:
- sudo -i
- cd /var/www/bd_test1
- sudo dep update -vvv --revision=""$CI_COMMIT_REF_NAME"" --init_config=""$BD_TEST1_INIT_CONFIG""
after_script:
- cd /var/www/bd_test1 && sudo dep deploy:unlock
environment:
name: review/bd_test1
url: https://bd-test1.saascredit.ru
when: manual
dependencies: [ ]
bd-test2:
stage: review
variables:
DEPLOY_CMD: 'dep update -vvv --revision="$CI_COMMIT_REF_NAME" --init_config="$BD_TEST2_INIT_CONFIG"'
only:
- web
- merge_requests
script:
- eval $(ssh-agent -s)
- ssh-add <(echo "$BD_TEST2_PRIVATE_KEY")
- ssh-keyscan -p 22422 test-srv >> ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
- ssh -o StrictHostKeyChecking=no saascredit@test-srv -p 22422 "cd /var/www/crm2 && sudo $DEPLOY_CMD"
after_script:
- eval $(ssh-agent -s)
- ssh-add <(echo "$BD_TEST2_PRIVATE_KEY")
- ssh -o StrictHostKeyChecking=no saascredit@test-srv -p 22422 "cd /var/www/crm2 && sudo dep deploy:unlock"
environment:
name: review/bd-test2
url: https://test2credit.bistrodengi.ru
when: manual
dependencies: []
dev:
stage: review
tags:
- bd-deploy
variables:
DEPLOY_CMD: 'dep update -vvv --revision="develop" --init_config="$CRM_INIT_CONFIG"'
only:
- web
- merge_requests
script:
- eval $(ssh-agent -s)
- ssh-add <(echo "$TEST_BD_PRIVATE_KEY")
- ssh -o StrictHostKeyChecking=no saas@testbd "cd /var/www/crm && $DEPLOY_CMD"
after_script:
- eval $(ssh-agent -s)
- ssh-add <(echo "$TEST_BD_PRIVATE_KEY")
- ssh -o StrictHostKeyChecking=no saas@testbd "cd /var/www/crm && dep deploy:unlock"
environment:
name: review/dev
url: http://sc.dev.mmk.local
when: manual
dependencies: [ ]
hotfix:
stage: review
tags:
- bd-deploy
variables:
DEPLOY_CMD: 'dep update -vvv --revision="$CI_COMMIT_REF_NAME" --init_config="$CRM1_INIT_CONFIG"'
only:
- web
- merge_requests
script:
- eval $(ssh-agent -s)
- ssh-add <(echo "$TEST_BD_PRIVATE_KEY")
- ssh -o StrictHostKeyChecking=no saas@testbd "cd /var/www/crm1 && sudo $DEPLOY_CMD"
after_script:
- eval $(ssh-agent -s)
- ssh-add <(echo "$TEST_BD_PRIVATE_KEY")
- ssh -o StrictHostKeyChecking=no saas@testbd "cd /var/www/crm1 && sudo dep deploy:unlock"
environment:
name: review/hotfix
url: http://sc.hotfix.mmk.local
when: manual
dependencies: [ ]
preprod:
stage: review
tags:
- bd-deploy
variables:
DEPLOY_CMD: 'dep update -vvv --revision="master" --init_config="$CRM2_INIT_CONFIG"'
only:
- web
- merge_requests
script:
- eval $(ssh-agent -s)
- ssh-add <(echo "$TEST_BD_PRIVATE_KEY")
- ssh -o StrictHostKeyChecking=no saas@testbd "cd /var/www/crm2 && sudo $DEPLOY_CMD"
after_script:
- eval $(ssh-agent -s)
- ssh-add <(echo "$TEST_BD_PRIVATE_KEY")
- ssh -o StrictHostKeyChecking=no saas@testbd "cd /var/www/crm2 && sudo dep deploy:unlock"
environment:
name: review/preprod
url: http://sc.preprod.mmk.local
when: manual
dependencies: [ ]
bd:
stage: deploy
variables:
DEPLOY_CMD: 'dep update -vvv --revision="master" --init_config="$BD_INIT_CONFIG"'
script:
- eval $(ssh-agent -s)
- ssh-add <(echo "$BD_PRIVATE_KEY")
- ssh-keyscan -p 22022 srv-app >> ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
- ssh -o StrictHostKeyChecking=no saascredit@srv-app -p 22022 "cd /var/www/crm && sudo $DEPLOY_CMD"
after_script:
- eval $(ssh-agent -s)
- ssh-add <(echo "$BD_PRIVATE_KEY")
- ssh -o StrictHostKeyChecking=no saascredit@srv-app -p 22022 "cd /var/www/crm && sudo dep deploy:unlock"
environment:
name: production/bd
url: https://credit.bistrodengi.ru
when: manual
dependencies: []
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment