-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gitlab-ci.yml
40 lines (33 loc) · 1.01 KB
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
image: registry.secoder.net/tool/deployer
stages:
- build
- test
- deploy
build:
stage: build
script:
- export BUILD_IMAGE_NAME=$CI_REGISTRY_IMAGE
- export BUILD_IMAGE_TAG=$CI_COMMIT_REF_SLUG
- export BUILD_IMAGE_USERNAME=$CI_REGISTRY_USER
- export BUILD_IMAGE_PASSWORD=$CI_REGISTRY_PASSWORD
- deployer build
test:
image: python:3.10
stage: test
before_script:
- pip install -i https://pypi.tuna.tsinghua.edu.cn/simple -r requirements.txt
script:
- export DEPLOY=$CI_REGISTRY_IMAGE
- python3 manage.py makemigrations
- python3 manage.py migrate
- sh unit-test.sh
after_script:
- SUFFIX=$RANDOM
- curl "http://api.secoder.net/static/sonar-scanner.tar.gz" -s -o "/tmp/sonar-$SUFFIX.tar.gz"
- tar -xf "/tmp/sonar-$SUFFIX.tar.gz" -C /opt
- /opt/sonar-scanner/bin/sonar-scanner
allow_failure: true
deploy:
stage: deploy
script:
- deployer dyno replace $CI_PROJECT_NAME "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" "$REGISTRY_USER" "$REGISTRY_PWD"