Created
August 7, 2017 14:18
-
-
Save htuscher/601e70db3d5265bac0717f52a14ab671 to your computer and use it in GitHub Desktop.
Neos Gitlab-CI
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
variables: | |
RSYNC: rsync -rtqx --chmod=Du=rwx,Dgo=rx,Fu=rw,Fog=r | |
SITE_PACKAGE: Vendor.Site | |
BASE_PATH: ${CI_PROJECT_DIR}/app/Packages/Sites/${SITE_PACKAGE}/ | |
LIVE_SERVER: [email protected] | |
cache: | |
key: ${CI_COMMIT_REF_NAME} | |
paths: | |
- .composercache | |
- app/Packages/Libraries | |
- app/Packages/Framework | |
- app/Packages/Application | |
- app/Build/Frontend/node_modules/ | |
- app/Packages/Sites/${SITE_PACKAGE}/Resources/Private/Bower/BowerComponents | |
stages: | |
- lint | |
- prepare | |
- build | |
- deploy | |
############# | |
# LINTING # | |
############# | |
lint:php: | |
stage: lint | |
image: 1drop/php-70-docker-utils | |
script: | |
- php-cs-fixer fix -v --dry-run --using-cache=no | |
lint:scss: | |
stage: lint | |
image: vendor/npm:myproj | |
script: | |
- cd /home/node/ | |
- yarn run sasslint | |
lint:js: | |
stage: lint | |
image: vendor/npm:myproj | |
script: | |
- cd /home/node/ | |
- yarn run eslint | |
lint:xlf: | |
stage: lint | |
image: 1drop/php-70-docker-utils | |
script: | |
- find ./app/Packages/Sites -type f -name "*.xlf" -print0 | xargs -0 -n1 /root/.composer/vendor/bin/xml-linter | |
####################### | |
# FRONTEND BUILDING # | |
####################### | |
build:npm:image: | |
stage: prepare | |
before_script: | |
- docker login -u myuser -p $DOCKER_HUB_PASS | |
script: | |
- docker build --pull --no-cache -t vendor/npm:myproj app/Build/Frontend | |
- docker push vendor/npm:myproj | |
when: manual | |
only: | |
- develop | |
frontend: | |
image: vendor/npm:myproj | |
stage: prepare | |
script: | |
- bower install --config.interactive=false --config.cwd=${BASE_PATH}Resources/Private/Bower/ install | |
- cd /home/node/ | |
- yarn run build | |
artifacts: | |
name: "$CI_COMMIT_REF_NAME" | |
paths: | |
- app/Packages/Sites/${SITE_PACKAGE}/Resources/Public/JavaScript | |
- app/Packages/Sites/${SITE_PACKAGE}/Resources/Public/Styles | |
only: | |
- master | |
- develop | |
########################## | |
# BUILD DOCKER DEV IMAGE # | |
########################## | |
neos_image: | |
image: docker:latest | |
stage: build | |
before_script: | |
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY | |
script: | |
- docker build --no-cache -f Dockerfile.ci -t $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME . | |
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME | |
only: | |
- develop | |
############### | |
# DEPLOYMENTS # | |
############### | |
deploy_stage: | |
image: 1drop/docker:git | |
stage: deploy | |
environment: | |
name: development | |
url: https://site.dev.vendor.com | |
before_script: | |
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY | |
script: | |
- export COMPOSE_PROJECT_NAME=someproj | |
- docker-compose -f docker-compose.stage.yml pull | |
- docker-compose -f docker-compose.stage.yml up -d | |
- docker exec -u application $(docker-compose -f docker-compose.stage.yml ps -q neos) ./flow flow:cache:flush --force | |
- docker exec -u application $(docker-compose -f docker-compose.stage.yml ps -q neos) rm Configuration/PackageStates.php | |
- docker exec -u application $(docker-compose -f docker-compose.stage.yml ps -q neos) ./flow doctrine:migrate | |
- docker exec -u application $(docker-compose -f docker-compose.stage.yml ps -q neos) ./flow resource:publish | |
only: | |
- develop | |
deploy_live: | |
image: 1drop/php-70-docker-utils | |
stage: deploy | |
environment: | |
name: production | |
url: https://www.someproj.com | |
before_script: | |
- eval $(ssh-agent -s) | |
- ssh-add <(echo "$SSH_PRIVATE_KEY") | |
- mkdir -p ~/.ssh | |
- echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config | |
- cd app | |
- composer config cache-files-dir .composercache | |
- composer install --no-dev --no-progress --no-interaction | |
script: | |
- $RSYNC --delete ./Packages/ $LIVE_SERVER:htdocs/Packages/ | |
- $RSYNC ./Configuration/ $LIVE_SERVER:htdocs/Configuration/ | |
- $RSYNC ./composer.* $LIVE_SERVER:htdocs/ | |
- ssh $LIVE_SERVER 'bash -s' < ../ci/deploy.sh | |
only: | |
- master | |
when: manual |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment