This GitLab CI configuration is valid. Learn more
.gitlab-ci.yml 1.90 KiB
stages:
  - prepare
  - build_app
  - tests
  - build
  - push
  - deploy


.registry:
  before_script:
    - echo -n $CI_REGISTRY_PASSWORD | podman login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY

buildapp:
  stage: build_app
  image: quay.io/podman/stable
  extends: .registry
  script:
    - podman pull ${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHORT_SHA}-dev || true
    - >
      podman build 
      --pull
      -f Dockerfile-dev
      --cache-from ${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHORT_SHA}-dev
      --tag ${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHORT_SHA}-dev
      .
    - podman push ${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHORT_SHA}-dev

tests:
  stage: tests
  image: ${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHORT_SHA}-dev
  script:
    - cd /app
    - npm run test:ci
    - cp -r /app/test_out $CI_PROJECT_DIR
  artifacts:
    reports:
      cobertura: test_out/cobertura-coverage.xml
      junit: test_out/junit.xml
   

build:
  stage: build
  image: quay.io/podman/stable
  extends: .registry
  script:
    - podman pull $CI_REGISTRY_IMAGE:latest || true
    - >
      podman build 
      --pull
      --build-arg APPVER=${CI_COMMIT_SHORT_SHA}-dev
      --build-arg APPIMAGE=${CI_REGISTRY_IMAGE}
      --cache-from $CI_REGISTRY_IMAGE:latest
      --tag $CI_REGISTRY_IMAGE:dev
      .

    - podman push $CI_REGISTRY_IMAGE:dev

push latest:
  variables:
    GIT_STRATEGY: none
  image: quay.io/podman/stable
  stage: push
  extends: .registry
  only:
    - master
  script:
    - podman pull $CI_REGISTRY_IMAGE:dev
    - podman tag $CI_REGISTRY_IMAGE:dev $CI_REGISTRY_IMAGE:latest
    - podman push $CI_REGISTRY_IMAGE:latest

push tag:
  variables:
    GIT_STRATEGY: none
  image: quay.io/podman/stable
  stage: push
  extends: .registry
  only:
    - tags
  script:
    - podman pull $CI_REGISTRY_IMAGE:dev
    - podman tag $CI_REGISTRY_IMAGE:dev $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME
    - podman push $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME