Skip to content
Snippets Groups Projects
.gitlab-ci.yml 1.88 KiB
Newer Older
Griefed's avatar
Griefed committed
test docker:
Griefed's avatar
Griefed committed
  # Use the official docker image.
  image: docker:latest
Griefed's avatar
Griefed committed
  stage: test
Griefed's avatar
Griefed committed
    - docker:dind
  before_script:
    - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
Griefed's avatar
Griefed committed
  # Default branch leaves tag empty (= latest tag)
  # All other branches are tagged with the escaped branch name (commit ref slug)
Griefed's avatar
Griefed committed
    - docker build -t $CI_REGISTRY_IMAGE$:develop -t index.docker.io/$DOCKERHUB_USER/$DOCKERHUB_REPO:develop .
    - docker push $CI_REGISTRY_IMAGE:develop index.docker.io/$DOCKERHUB_USER/$DOCKERHUB_REPO:develop
Griefed's avatar
Griefed committed
  # Run this job in a branch where a Dockerfile exists
  rules:
    - if: $CI_COMMIT_BRANCH
      exists:
        - Dockerfile


release:
  needs: ['test docker']
  stage: release
  image: registry.griefed.de/prosper/gitlab-semantic-release:latest
  services:
    - name: docker:dind
      alias: docker
  variables:
    project_name: $CI_PROJECT_NAME
    SEMANTIC_RELEASE_PACKAGE: $CI_PROJECT_NAME
  script:
    - npx semantic-release
  only:
    - master
  except:
    refs:
      - tags
    variables:
      - $CI_COMMIT_TITLE =~ /^RELEASE:.+$/

Griefed's avatar
Griefed committed
build docker:
Griefed's avatar
Griefed committed
  # Use the official docker image.
  image: docker:latest
Griefed's avatar
Griefed committed
    - docker:dind
  before_script:
    - docker login -u "$DOCKERHUB_USER" -p "$DOCKERHUB_TOKEN" docker.io
    - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
Griefed's avatar
Griefed committed
  # Default branch leaves tag empty (= latest tag)
  # All other branches are tagged with the escaped branch name (commit ref slug)
Griefed's avatar
Griefed committed
    - docker build -t $CI_REGISTRY_IMAGE$:latest -t index.docker.io/$DOCKERHUB_USER/$DOCKERHUB_REPO:latest .
    - docker push $CI_REGISTRY_IMAGE:latest index.docker.io/$DOCKERHUB_USER/$DOCKERHUB_REPO:latest
Griefed's avatar
Griefed committed
  # Run this job in a branch where a Dockerfile exists
  rules:
    - if: $CI_COMMIT_BRANCH
      exists:
        - Dockerfile