.gitlab-ci.yml 1.15 KB
Newer Older
tr's avatar
tr committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
---
stages:
  - build
  - test
  - deploy

build:
  stage: build
  tags:
    - dind
  script:
    - docker version
    - docker build --no-cache -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME" .
    - docker login -u gitlab-ci-token -p "$CI_JOB_TOKEN" "$CI_REGISTRY"
    - docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME"

test:
  stage: test
  tags:
    - docker
  image:
    name: "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME"
  script:
    - echo "Image $CI_REGISTRY_IMAGE $CI_COMMIT_REF_NAME"
tr's avatar
tr committed
25
    - touch /etc/modsecurity/rules/site-rules.conf
tr's avatar
tr committed
26
27
    - nginx -t 2>&1 | grep ModSecurity-nginx
    - test -x /usr/local/bin/modsec-rules-check
tr's avatar
tr committed
28
    - test -f /etc/modsecurity/coreruleset/crs-setup.conf
tr's avatar
tr committed
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44

deploy latest:
  stage: deploy
  tags:
    - dind
  rules:
    - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
  script:
    - docker version
    - docker login -u gitlab-ci-token -p "$CI_JOB_TOKEN" "$CI_REGISTRY"
    - docker pull "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME"
    - docker tag "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME" "$CI_REGISTRY_IMAGE:latest"
    - docker rmi "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME"
    - docker push "$CI_REGISTRY_IMAGE:latest"

# vim: set ts=2 sw=2 :