.gitlab-ci.yml 1.91 KB
Newer Older
1
stages:
Matthieu Boileau's avatar
Matthieu Boileau committed
2
  - deps
3
4
  - build
  - deploy
Matthieu Boileau's avatar
Matthieu Boileau committed
5
  - post-deploy
6

Matthieu Boileau's avatar
Matthieu Boileau committed
7
8
deps:
  stage: deps
Matthieu Boileau's avatar
Matthieu Boileau committed
9
  tags:
Matthieu Boileau's avatar
Matthieu Boileau committed
10
    - pelican
Matthieu Boileau's avatar
Matthieu Boileau committed
11
  script:
12
    - echo "Building $CI_REGISTRY_IMAGE"
Matthieu Boileau's avatar
Matthieu Boileau committed
13
14
    - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
    - docker info
Matthieu Boileau's avatar
Matthieu Boileau committed
15
16
    - docker build --pull -t $CI_REGISTRY_IMAGE -f ./docker/Dockerfile .
    - docker push $CI_REGISTRY_IMAGE
17

18
19
build:
  stage: build
Matthieu Boileau's avatar
Matthieu Boileau committed
20
  image: $CI_REGISTRY_IMAGE
21
  tags:
Matthieu Boileau's avatar
Matthieu Boileau committed
22
    - docker
23
  script:
Matthieu Boileau's avatar
Matthieu Boileau committed
24
    - echo "Building website using docker image $CI_REGISTRY_IMAGE"
25
    - pelican -s publishconf.py --fatal errors
Matthieu Boileau's avatar
Matthieu Boileau committed
26
27
  artifacts:
    untracked: true
Matthieu Boileau's avatar
Matthieu Boileau committed
28
    expire_in: 1 hour
29

30
31
apache-dev:
  stage: deploy
Matthieu Boileau's avatar
Matthieu Boileau committed
32
  tags:
Matthieu Boileau's avatar
Matthieu Boileau committed
33
    - pelican
Matthieu Boileau's avatar
Matthieu Boileau committed
34
35
  variables:
    PUBLISH_DIR: "/var/www/calcul-dev/$CI_COMMIT_REF_NAME"
36
  only:
37
    - develop
38
    - /^dev-.*$/
Matthieu Boileau's avatar
Matthieu Boileau committed
39
40
  dependencies:
    - build
41
  script:
Matthieu Boileau's avatar
Matthieu Boileau committed
42
    - echo "Publishing to $PUBLISH_DIR"
Matthieu Boileau's avatar
Matthieu Boileau committed
43
    - rsync -av --delete --exclude 'attachments' output/ $PUBLISH_DIR/
Matthieu Boileau's avatar
Matthieu Boileau committed
44
    - rsync -av --delete content/attachments/ $PUBLISH_DIR/attachments/
45
    - chmod a+w $PUBLISH_DIR/job_offers/flood
46
47
48
49

apache:
  stage: deploy
  tags:
Matthieu Boileau's avatar
Matthieu Boileau committed
50
    - pelican
51
  variables:
Matthieu Boileau's avatar
Matthieu Boileau committed
52
    PUBLISH_DIR: "/var/www/html"
53
54
  only:
    - master
Matthieu Boileau's avatar
Matthieu Boileau committed
55
56
  dependencies:
    - build
57
  script:
Matthieu Boileau's avatar
Matthieu Boileau committed
58
    - echo "Publishing to $PUBLISH_DIR"
59
60
    - rsync -av --delete --exclude 'attachments' output/ $PUBLISH_DIR/
    - rsync -av --delete content/attachments/ $PUBLISH_DIR/attachments/
61
    - chmod a+w $PUBLISH_DIR/job_offers/flood
62

Matthieu Boileau's avatar
Matthieu Boileau committed
63
64
65
66
67
68
69
70
71
72
73
notify-job-offer-author:
  stage: post-deploy
  image: $CI_REGISTRY_IMAGE
  tags:
    - docker
  only:
    refs:
      - master
    variables:
      - $CI_COMMIT_TITLE =~ /^Merge branch 'job_.*$/
  script:
Matthieu Boileau's avatar
Matthieu Boileau committed
74
75
    - python3 utils/notify_job_offer.py --commit_title "$CI_COMMIT_TITLE" --password $SENDER_PASSWORD --notifier author --publisher "$GITLAB_USER_NAME"
    - python3 utils/notify_job_offer.py --commit_title "$CI_COMMIT_TITLE" --password $SENDER_PASSWORD --notifier list --recipient_email $GITLAB_USER_EMAIL --publisher "$GITLAB_USER_NAME"
Matthieu Boileau's avatar
Matthieu Boileau committed
76