ci: Rebuild docker images any time a commit touches the dockerfile

Currently they are built from cron, but we can use Gitlab's

  only:
    changes:
      - path

support to also trigger on path changes. This is restricted to only work
for pushes for master, so that branches / merge requests don't attempt
to rebuild the image.
This commit is contained in:
Iain Lane 2019-02-20 11:14:09 +00:00 committed by Georges Basile Stavracas Neto
parent 75c47ee7c9
commit e83fd09949

View file

@ -354,6 +354,9 @@ ppc64le:
only: only:
variables: variables:
- $CRON_TASK == "BUILD_CI_IMAGES" - $CRON_TASK == "BUILD_CI_IMAGES"
changes:
- build-aux/ci/Dockerfile.*
script: script:
# Skip the build (if requested) # Skip the build (if requested)
@ -363,6 +366,19 @@ ppc64le:
exit 0 exit 0
fi fi
- |
if [[ "${CI_COMMIT_REF_NAME}" != "master" ]]; then
echo "== Exiting, will only build CI images when pushing to master. =="
exit 0
fi
# Only when we have somewhere to publish to
- |
if [[ -z "${CI_REGISTRY}${CI_REGISTRY_IMAGE}${CI_REGISTRY_USER}${CI_REGISTRY_PASSWORD}" ]]; then
echo "== Exiting, CI registry not configured. =="
exit 0
fi
# Get multiarch stuff # Get multiarch stuff
- | - |
if [[ -n "${TARGET_ARCH}" ]]; then if [[ -n "${TARGET_ARCH}" ]]; then
@ -373,16 +389,11 @@ ppc64le:
# Build using the Dockerfile # Build using the Dockerfile
- docker build -f "$DOCKERFILE" -t "$CI_REGISTRY_IMAGE:$NAME" . - docker build -f "$DOCKERFILE" -t "$CI_REGISTRY_IMAGE:$NAME" .
# Prepare to publish # Publish
- docker tag "$CI_REGISTRY_IMAGE:$NAME" "$CI_REGISTRY_IMAGE:job-"$CI_JOB_ID"_$NAME" - docker tag "$CI_REGISTRY_IMAGE:$NAME" "$CI_REGISTRY_IMAGE:job-"$CI_JOB_ID"_$NAME"
- docker images - docker images
- docker login ${CI_REGISTRY} -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD} - docker login ${CI_REGISTRY} -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD}
- docker push "$CI_REGISTRY_IMAGE"
# Publish (if running on a schedule)
- |
if [[ "${CI_PIPELINE_SOURCE}" == "schedule" ]]; then
docker push "$CI_REGISTRY_IMAGE"
fi
fedora.dev: fedora.dev:
<<: *create_docker_image <<: *create_docker_image