forked from Flagsmith/flagsmith
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
81 lines (74 loc) · 2.2 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
stages:
- test
- build
- deploy
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- .venv/
test:
image: python:3.7-slim
stage: test
services:
- postgres:10.9-alpine
variables:
DJANGO_SETTINGS_MODULE: "app.settings.test"
DATABASE_URL: postgres://testuser:testpass@postgres/test_db
POSTGRES_USER: testuser
POSTGRES_PASSWORD: testpass
script:
- pip install virtualenv # set up local venv dir for caching of packages
- virtualenv .venv
- source .venv/bin/activate
- pip install -r requirements-dev.txt
- black --check .
- pytest src -p no:warnings
build-dockerhub:
stage: build
tags:
- flagsmith-shell-runner
script:
- if [ "$CI_COMMIT_REF_NAME" == "master" ]; then IMAGE_TAG="latest"; else IMAGE_TAG=$CI_COMMIT_REF_SLUG; fi
- echo $CI_COMMIT_REF_NAME > $CI_PROJECT_DIR/src/CI_COMMIT_REF_NAME
- echo $CI_COMMIT_SHA > $CI_PROJECT_DIR/src/CI_COMMIT_SHA
- echo $IMAGE_TAG > $CI_PROJECT_DIR/src/IMAGE_TAG
- docker login --username $DOCKER_HUB_PUSH_USERNAME_SHELL_RUNNER -p $DOCKER_HUB_PUSH_PASSWORD_SHELL_RUNNER
- docker build -t flagsmith/flagsmith-api:$IMAGE_TAG -f $CI_PROJECT_DIR/docker/Dockerfile .
- docker push flagsmith/flagsmith-api:$IMAGE_TAG
only:
- master
- tags
- develop
deploydevelop:
image: ilyasemenov/gitlab-ci-git-push
stage: deploy
script: git-push [email protected]:bullet-train
only:
- develop
.deploy_to_beanstalk: &deploy_to_beanstalk |
echo "Deploying to beanstalk with label $CI_COMMIT_SHORT_SHA"
cp requirements.txt ./src/requirements.txt
cd src
eb deploy $ENVIRONMENT_NAME -l "$CI_COMMIT_SHORT_SHA"
deployawsstaging:
image: flagsmith/eb-cli:latest
stage: deploy
variables:
ENVIRONMENT_NAME: staging-api
AWS_ACCESS_KEY_ID: "$AWS_STAGING_ACCESS_KEY_ID"
AWS_SECRET_ACCESS_KEY: "$AWS_STAGING_SECRET_ACCESS_KEY"
script:
- *deploy_to_beanstalk
only:
- staging
deployawsmaster:
image: flagsmith/eb-cli:latest
stage: deploy
variables:
ENVIRONMENT_NAME: production-api
AWS_ACCESS_KEY_ID: "$AWS_PRODUCTION_ACCESS_KEY_ID"
AWS_SECRET_ACCESS_KEY: "$AWS_PRODUCTION_SECRET_ACCESS_KEY"
script:
- *deploy_to_beanstalk
only:
- master