summaryrefslogtreecommitdiff
path: root/.gitlab-ci.yml
blob: cf08caa08bc2c86302fb17b927b34e72003953de (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
variables:
  CI_BUILD_IMAGE: $CI_REGISTRY_IMAGE/zmk-build

build:
  rules:
    - if: '$CI_COMMIT_REF_SLUG =~ /^docker/'
      when: never
    - when: on_success

  cache:
    paths:
      - ci-workspace/modules
      - ci-workspace/tools
      - ci-workspace/zephyr
      - ci-workspace/bootloader

  image: $CI_BUILD_IMAGE:v0.1.1

  variables:
    GIT_CLONE_PATH: $CI_BUILDS_DIR/zmk

  before_script:
    - mkdir ci-workspace && ln -s $(pwd) ci-workspace/zmk
    - cd ci-workspace/zmk
    - west init -l .
    - west update
    - west config --global zephyr.base-prefer configfile
    - west zephyr-export

  script:
    - cd ci-workspace/zmk
    - west build -b nucleo_wb55rg -- -DSHIELD=petejohanson_handwire

build:dockerimage:
  services:
    - docker:stable-dind

  image: docker:stable

  rules:
    - if: '$CI_COMMIT_REF_SLUG =~ /^docker/'
      when: always

  before_script:
  - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY

  script:
    - docker pull $CI_BUILD_IMAGE:latest || true
    - docker build --cache-from $CI_BUILD_IMAGE:latest -t $CI_BUILD_IMAGE:$CI_COMMIT_SHORT_SHA .
    - docker push $CI_BUILD_IMAGE:$CI_COMMIT_SHORT_SHA
    - docker tag $CI_BUILD_IMAGE:$CI_COMMIT_SHORT_SHA $CI_BUILD_IMAGE:latest && docker push $CI_BUILD_IMAGE:latest
    - if [ -n "$CI_COMMIT_TAG" ]; then docker tag $CI_BUILD_IMAGE:$CI_COMMIT_SHORT_SHA $CI_BUILD_IMAGE:${CI_COMMIT_TAG#docker-} && docker push $CI_BUILD_IMAGE:${CI_COMMIT_TAG#docker-}; fi