aboutsummaryrefslogtreecommitdiffstats
path: root/gitlab-ci-template-nocache.yml
blob: e5b8caedc8064a2993595888ee33ca7ac41c2fa7 (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
# https://blog.callr.tech/building-docker-images-with-gitlab-ci-best-practices/
# comments dropped, updated for podman builds
# this variant builds without caching

image: registry.gitlab.com/kraxel/podman-docker-builder:latest

stages:
  - build
  - push

before_script:
  - podman login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY

Build:
  stage: build
  script:
    - >
      podman build
      --build-arg VCS_REF=$CI_COMMIT_SHA
      --build-arg VCS_URL=$CI_PROJECT_URL
      --tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
      .
    - podman push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA

Push latest:
  variables:
    GIT_STRATEGY: none
  stage: push
  only:
    - master
  script:
    - podman pull $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
    - podman tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA $CI_REGISTRY_IMAGE:latest
    - podman push $CI_REGISTRY_IMAGE:latest

Push tag:
  variables:
    GIT_STRATEGY: none
  stage: push
  only:
    - tags
  script:
    - podman pull $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
    - podman tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME
    - podman push $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME