git-annex/.gitlab-ci.yml
2023-01-13 19:24:50 +01:00

41 lines
1.3 KiB
YAML

# SPDX-FileCopyrightText: 2023 Tobias Schmidl
# SPDX-License-Identifier: CC0-1.0
reuse:
image:
name: fsfe/reuse:latest
entrypoint: [""]
script:
- reuse lint
docker-build:
image: docker:latest
stage: build
services:
- docker:dind
before_script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
# Default branch leaves tag empty (= latest tag)
# All other branches are tagged with the escaped branch name (commit ref slug)
script:
- |
if [[ "$CI_COMMIT_BRANCH" == "$CI_DEFAULT_BRANCH" ]]; then
tag=""
echo "Running on default branch '$CI_DEFAULT_BRANCH': tag = 'latest'"
else
tag=":$CI_COMMIT_REF_SLUG"
echo "Running on branch '$CI_COMMIT_BRANCH': tag = $tag"
fi
- |
docker build --pull \
--label org.label-schema.build-date=$(date -u +'%FT%H:%M:%SZ') \
--label org.label-schema.name="${NAME}" --label org.label-schema.vcs-url="${CI_PROJECT_URL}" \
--label org.label-schema.vcs-ref="${CI_COMMIT_SHA:0:8}" \
-t "${CI_REGISTRY_IMAGE}/${CI_COMMIT_REF_NAME}:${CI_COMMIT_SHA:0:8}" -t "$CI_REGISTRY_IMAGE${tag}" .
- docker push "$CI_REGISTRY_IMAGE${tag}"
# Run this job in a branch where a Dockerfile exists
rules:
- if: $CI_COMMIT_BRANCH
exists:
- Dockerfile