-
-# Script to check if a docker image exists in the upstream registry
-# and if so copy it to the forked registry so we can use it
-#
-# This is copied/adapted from citemplates/templates/fedora.yml
-# https://gitlab.freedesktop.org/freedesktop/ci-templates/-/blob/96b621fe9f57ec2464f8d1a0940446afbf6c8f59/templates/fedora.yml
-.check_image: &check_image_exists |
- # if-not-exists steps
- set -x
-
- if [[ -z "$GST_FORCE_REBUILD" ]]
- then
- # disable exit on failure
- set +e
-
- # check if our image is already in the current registry
- # we store the sha of the digest and the layers
- skopeo inspect docker://$LOCAL_IMAGE | jq '[.Digest, .Layers]' > local_sha
-
- # check if our image is already in our gst-ci registry fork
- skopeo inspect docker://$LOCAL_GST_CI_IMAGE | jq '[.Digest, .Layers]' > local_gst_ci_sha
-
- # check if our image is already in the upstream registry
- if [[ -z "$GST_UPSTREAM_REPO" ]]
- then
- echo "WARNING! Variable \$GST_UPSTREAM_REPO is undefined, cannot check for images"
- else
- skopeo inspect docker://$GST_UPSTREAM_IMAGE | jq '[.Digest, .Layers]' > upstream_sha
- fi
-
- # reenable exit on failure
- set -e
-
- # if the upstream repo has an image, ensure we use the same
- if [ -s upstream_sha ]
- then
-
- echo "Checking if $LOCAL_IMAGE is up to date"
- # ensure we use the same image from upstream
- diff upstream_sha local_sha && exit 0 || true
-
- echo "Copying image from gstreamer/gst-ci to local registry"
- # copy the original image into the current project registry namespace
- # we do 2 attempts with skopeo copy at most
- skopeo copy --dest-creds $CI_REGISTRY_USER:$CI_REGISTRY_PASSWORD \
- docker://$GST_UPSTREAM_IMAGE \
- docker://$LOCAL_IMAGE || \
- skopeo copy --dest-creds $CI_REGISTRY_USER:$CI_REGISTRY_PASSWORD \
- docker://$GST_UPSTREAM_IMAGE \
- docker://$LOCAL_IMAGE
-
- exit 0
- fi
-
- set +x
-
- # if the local ci fork repo has an image, ensure we use the same
- if [ -s local_gst_ci_sha ]
- then
- echo "Checking if $LOCAL_GST_CI_IMAGE is up to date"
- # ensure we use the same image from upstream
- diff local_gst_ci_sha local_sha && exit 0 || true
-
- echo "Copying image from $CI_PROJECT_NAMESPACE/gst-ci to local registry"
- # copy the original image into the current project registry namespace
- # we do 2 attempts with skopeo copy at most
- skopeo copy --dest-creds $CI_REGISTRY_USER:$CI_REGISTRY_PASSWORD \
- docker://$LOCAL_GST_CI_IMAGE \
- docker://$LOCAL_IMAGE || \
- skopeo copy --dest-creds $CI_REGISTRY_USER:$CI_REGISTRY_PASSWORD \
- docker://$LOCAL_GST_CI_IMAGE \
- docker://$LOCAL_IMAGE
-
- exit 0
- fi
-
- # if we have a local image but none in the upstream repo, use our
- if [ -s local_sha ]
- then
- echo "Using $LOCAL_IMAGE"
- exit 0
- fi
- fi
-
-
-# Build docker images from Dockerfiles
-#
-# This is copied/adapted from citemplates/templates/fedora.yml
-# https://gitlab.freedesktop.org/freedesktop/ci-templates/-/blob/96b621fe9f57ec2464f8d1a0940446afbf6c8f59/templates/fedora.yml
-#
-# CITemplates builds uses buildah run/commit workflow to build the images which doesn't
-# fit us atm and our images need further adjustment to make use of it. Porting to
-# ci-templates is the next step though.
-#
-# All the documentation from citemplates should be applicable here, so please refer there
-.base:
- image: "$CI_REGISTRY/freedesktop/ci-templates/buildah:2020-07-20.1"