-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
48 lines (41 loc) · 1.56 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
variables:
APP_CONTAINER: "$CI_REGISTRY_IMAGE/borderlands-scraper:$CI_COMMIT_REF_SLUG"
BUILD_CACHE: "$CI_REGISTRY_IMAGE/borderlands-scraper:build_cache"
BORDERLANDS_ENCRYPTION_KEY: "$BORDERLANDS_ENCRYPTION_KEY"
TWITTER_ACCESS_TOKEN: "$TWITTER_ACCESS_TOKEN"
TWITTER_ACCESS_TOKEN_SECRET: "$TWITTER_ACCESS_TOKEN_SECRET"
TWITTER_CONSUMER_KEY: "$TWITTER_CONSUMER_KEY"
TWITTER_CONSUMER_SECRET: "$TWITTER_CONSUMER_SECRET"
# Build stage also runs tests on container and pushes to GitLab repository
stages:
- build
- deploy
services:
- docker:18.09.7-dind
build:
image: docker:18.09.7
stage: build
script:
# Use previously built container as cache to speed up build.
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
- docker pull "$BUILD_CACHE" || true
- >
docker build
--cache-from "$BUILD_CACHE"
-t "$APP_CONTAINER" .
# Tag APP_CONTAINER as new build cache and then push to repo
- docker tag "$APP_CONTAINER" "$BUILD_CACHE"
- docker push "$BUILD_CACHE"
# Run container tests
# - >
# docker run
# -e BORDERLANDS_ENCRYPTION_KEY=$BORDERLANDS_ENCRYPTION_KEY
# -e TWITTER_ACCESS_TOKEN=$TWITTER_ACCESS_TOKEN
# -e TWITTER_ACCESS_TOKEN_SECRET=$TWITTER_ACCESS_TOKEN_SECRET
# -e TWITTER_CONSUMER_KEY=$TWITTER_CONSUMER_KEY
# -e TWITTER_CONSUMER_SECRET=$TWITTER_CONSUMER_SECRET
# --rm "$APP_CONTAINER" pytest -vs tests
- docker run --rm "$APP_CONTAINER" flake8
# Push container to gitlab registry
- docker push "$APP_CONTAINER"
allow_failure: false