summarylogtreecommitdiffstats
path: root/.gitlab-ci.yml
blob: ef4970913ce1651c507972165ecb78395937fea4 (plain)
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
variables:
  DOCKER_IMAGE: archlinux:base-devel
  SCHEDULE_TASK: default
  PKGDEST: ./build

stages:
  - build
  - deploy

makepkg:
  stage: build
  image: ${DOCKER_IMAGE}
  cache:
    - key:
        files:
          - '*'
      paths:
        - /var/cache/pacman/pkg
        - /build
  before_script:
      - pacman -Sy --noconfirm --noprogressbar
      - useradd -d /build -m build
      - "echo 'build ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers"
      - su build -c "mkdir -p ./build"
  script:
      - export PKGDEST=${PKGDEST}
      - su build -c "/usr/bin/makepkg -s --noconfirm --noprogressbar"
  artifacts:
    paths:
      - ${PKGDEST}
    expire_in: 1 week
  tags: [""]
  rules:
    - if: $CI_PIPELINE_SOURCE == "schedule"
      when: never
    - when: always
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
      when: always
    - if: $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH
      when: manual

# Deploys the generated package to Gitlab pages name.gitlab.io/repo_name
pages:
  variables:
    BUILD_OUTPUT_PATH: ${CI_PROJECT_DIR}/repo
  stage: deploy
  image: alpine:latest
  before_script:
    - apk add rsync
    # replace html assets relative path with pages absolute path
    - find $BUILD_OUTPUT_PATH \( -type d -name .git -prune \) -o -type f -print0 | xargs -0 sed -i -e "s#href=\"\/#href=\"$CI_PAGES_URL/#g" -e "s#src=\"\/#src=\"$CI_PAGES_URL/#g"
  script:
    - mkdir public || true
    - rsync -av --exclude='public' --exclude='.git' $BUILD_OUTPUT_PATH/ public
  artifacts:
    paths:
      - public
    expire_in: 1 week
  rules:
    - if: $CI_PIPELINE_SOURCE == "schedule"
      when: never
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
      when: always