-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
90 lines (81 loc) · 2.07 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
82
83
84
85
86
87
88
89
90
image: haskell:8.0.1
services:
- postgres:latest
- docker:latest
cache:
key: "$CI_BUILD_NAME/$CI_BUILD_REF_NAME"
untracked: true
paths:
- .stack-work/
- "~/docker"
- "~/.cabal"
- "~/.local"
- "~/.stack"
before_script:
- apt-get update -qq;
- apt-get install -y -qq libpq-dev
- stack setup;
# Defines the stages in the Gitlab-CI Pipeline
stages:
- prepare
- build
- cleanup_build
- test
- deploy
build_deps:
stage: prepare
artifacts:
when: always
expire_in: 1 week
paths:
- /root/.stack/
- .stack-work/
script:
- echo "Artifacts in " /root/.stack
- stack setup;
- stack build --only-dependencies
- ls /root/.stack/
- ls .stack-work/
build_job:
stage: build
script:
- stack build --no-terminal howl-backend
only:
- branches
except:
- triggers
build-clean-job:
script:
- stack --no-terminal clean
when: on_failure
test_job:
stage: test
script:
- stack --no-terminal test howl-backend:howl-backend-test --coverage
only:
- branches
- /^v\d+\.\d+\.\d+-.*$/
except:
- triggers
### DEPLOY ####################################################
deploy-job:
stage: deploy #assigns the stage as deploy
# Script to run for deploying application to AWS
script:
- apt-get --quiet install --yes python-pip # AWS CLI requires python-pip, python is installed by default
- apt-get --quiet install --yes curl
- curl -sSL https://get.docker.com/ | sh
- docker -d;
- pip install -U pip # pip update
- pip install awscli # AWS CLI installation
- stack --no-terminal install --local-bin-path .
- docker build --rm=false -t $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$AWS_REPO_NAME:$CI_BUILD_REF -f Dockerfile.deploy .
- ./deploy.sh $CI_BUILD_REF
# requires previous CI stages to succeed in order to execute
when: on_success
environment: production # Assign the Gitlab Environment for tracking purposes
# Applies only to tags matching the regex: ie: v1.0.0-My-App-Release
only:
- master
except:
- triggers