77 lines
1.8 KiB
YAML
77 lines
1.8 KiB
YAML
stages:
|
|
- test
|
|
- lint
|
|
- publish
|
|
- deploy
|
|
|
|
test:
|
|
image: python:3.5
|
|
stage: test
|
|
services:
|
|
- postgres:latest
|
|
variables:
|
|
POSTGRES_DB: ci
|
|
POSTGRES_USER: postgres
|
|
POSTGRES_PASSWORD: postgres
|
|
DATABASE_URL: "postgresql://postgres:postgres@postgres:5432/$POSTGRES_DB"
|
|
script:
|
|
- python -V
|
|
- pip install -r requirements.txt
|
|
- cp sikweb/settings-sample.py sikweb/default_settings.py
|
|
- cp sikweb/.ci-settings.py sikweb/settings.py
|
|
- python manage.py migrate --noinput
|
|
- python manage.py createdefaultadmin
|
|
- python manage.py test
|
|
|
|
pep8:
|
|
image: python:3.5
|
|
stage: lint
|
|
script:
|
|
- pip install pep8
|
|
- pep8 --config=setup.cfg --count .
|
|
|
|
eslint:
|
|
image: node:7.10.0
|
|
stage: lint
|
|
before_script:
|
|
- npm install
|
|
script:
|
|
- npm run eslint
|
|
|
|
remark:
|
|
image: node:7.10.0
|
|
stage: lint
|
|
before_script:
|
|
- npm install
|
|
script:
|
|
- npm run remark
|
|
|
|
publish:
|
|
stage: publish
|
|
image: docker:latest
|
|
only:
|
|
- develop
|
|
before_script:
|
|
- docker info
|
|
script:
|
|
- docker build . -t "$IMAGE_NAME"
|
|
- docker push "$IMAGE_NAME"
|
|
|
|
deploy:
|
|
stage: deploy
|
|
image: alpine:latest
|
|
environment:
|
|
name: dev
|
|
url: http://web.sik.party
|
|
before_script:
|
|
- pwd
|
|
- apk add --update openssh
|
|
- ssh -V
|
|
- mkdir -p ~/.ssh
|
|
- echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
|
|
- chmod 600 ~/.ssh/id_rsa
|
|
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
|
|
script:
|
|
- scp docker-compose.yml $SSH_USER@$SSH_HOST:~/deployment/docker-compose.yml
|
|
- ssh $SSH_USER@$SSH_HOST 'cd deployment && docker-compose down && docker-compose pull "$IMAGE_NAME" && docker-compose up -d'
|