summaryrefslogtreecommitdiff
path: root/ci/gitlab/container-templates.yml
blob: a577028d1107b419552cda2aef7c0059dac63500 (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
# THIS FILE WAS AUTO-GENERATED
#
#  $ lcitool manifest ci/manifest.yml
#
# https://gitlab.com/libvirt/libvirt-ci


# We want to publish containers with tag 'latest':
#
#  - In upstream, for push to default branch with CI changes.
#  - In upstream, on request, for scheduled/manual pipelines
#    against default branch
#
# Note: never publish from merge requests since they have non-committed code
#
.container_job:
  image: docker:stable
  stage: containers
  needs: []
  services:
    - docker:dind
  before_script:
    - export TAG="$CI_REGISTRY_IMAGE/ci-$NAME:latest"
    - docker info
    - docker login "$CI_REGISTRY" -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD"
  script:
    - docker build --tag "$TAG" -f "ci/containers/$NAME.Dockerfile" ci/containers ;
    - docker push "$TAG"
  after_script:
    - docker logout
  rules:
    # upstream: publish containers if there were CI changes on the default branch
    - if: '$CI_PROJECT_NAMESPACE == $RUN_UPSTREAM_NAMESPACE && $CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
      when: on_success
      changes:
        - ci/gitlab/container-templates.yml
        - ci/containers/$NAME.Dockerfile

    # upstream: allow force re-publishing containers on default branch for web/api/scheduled pipelines
    - if: '$CI_PROJECT_NAMESPACE == $RUN_UPSTREAM_NAMESPACE && $CI_PIPELINE_SOURCE =~ /(web|api|schedule)/ && $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH && $RUN_CONTAINER_BUILDS == "1"'
      when: on_success

    # upstream+forks: that's all folks
    - when: never