.gitlab-ci.yml 1.49 KB
Newer Older
betz's avatar
betz committed
1
#image: registry.gitlab.com/pages/hugo:latest
betz's avatar
betz committed
2 3
#image: klakegg/hugo:alpine
image: monachus/hugo
betz's avatar
betz committed
4

Betz's avatar
Betz committed
5 6 7
stages:
  - Build
  - Deploy
Betz's avatar
Betz committed
8
  - Notify
betz's avatar
CI  
betz committed
9 10

before_script:
betz's avatar
CI  
betz committed
11
  - apt-get update
betz's avatar
betz committed
12
  - apt-get install openssh-client tree -y
betz's avatar
CI  
betz committed
13
  - eval $(ssh-agent -s)
betz's avatar
CI  
betz committed
14
  - echo "$PRIVKEY" | tr -d '\r' | ssh-add - > /dev/null
betz's avatar
CI  
betz committed
15 16
  - mkdir -p ~/.ssh
  - chmod 700 ~/.ssh
betz's avatar
betz committed
17 18 19
  - echo "$KNOWN_HOSTS" > ~/.ssh/known_hosts
  - chmod 644 ~/.ssh/known_hosts

betz's avatar
CI  
betz committed
20

Betz's avatar
Betz committed
21 22
Build:
  stage: Build
betz's avatar
betz committed
23 24
  variables:
    GITLAB_USER_LOGIN: $GITLAB_USER_LOGIN
betz's avatar
betz committed
25 26
    CI_BUILD_REF: $CI_BUILD_REF
    CI_COMMIT_MESSAGE: $CI_COMMIT_MESSAGE
betz's avatar
betz committed
27
    MESSAGE: $CI_COMMIT_MESSAGE
betz's avatar
betz committed
28
  script:
betz's avatar
betz committed
29
  - ./scripts/commits.sh content data/commits
Betz's avatar
Betz committed
30
  - rm -f data/commits/8cb8eade5f2a2572d6df34091c9c7d12.json
Betz's avatar
Betz committed
31
  - rm -f data/commits/932529a948a5717a9894cf3b4e361a69.json
32
  - curl 'https://gitlab.com/api/v4/projects/hsbxl%2Fsite/repository/commits?private_token='$GITLAB_API_KEY > 'data/changelog/changelog.json'
betz's avatar
betz committed
33 34
  - hugo version
  - hugo
betz's avatar
betz committed
35
  artifacts:
Betz's avatar
Betz committed
36
    expire_in: 1 day
betz's avatar
betz committed
37 38 39 40
    paths:
    - public
  only:
  - master
Betz's avatar
Betz committed
41

Betz's avatar
Betz committed
42 43
Deploy:
  stage: Deploy
Betz's avatar
Betz committed
44 45 46
  script:
    - echo $(date +%Y.%m.%d)
    - tar cz public | ssh [email protected] "mkdir -p /www/versions/$(date +%Y.%m.%d); cd /www/versions/$(date +%Y.%m.%d); tar xz; rm /www/live; ln -sf versions/$(date +%Y.%m.%d)/public /www/live"
Betz's avatar
Betz committed
47 48

Notify:
Betz's avatar
Betz committed
49
  stage: Notify
Betz's avatar
Betz committed
50 51
  script:
    - curl -XPOST -d '{"msgtype":"m.text", "body":"Site updated."}' "https://hackerspaces.be/_matrix/client/r0/rooms/!mnQLxCDhwmKozNmuIB:hackerspaces.be/send/m.room.message?access_token=$MATRIX_ACCESS_TOKEN"