#!/bin/sh

PARENT_COMMIT=`git rev-list --parents -n 1 HEAD  | cut -d' ' -f2`

docker login "https://${CI_REGISTRY}" -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD

docker pull $CI_REGISTRY_IMAGE:$PARENT_COMMIT-elixir-builder || \
  docker pull $CI_REGISTRY_IMAGE:latest-elixir-builder || \
  true

docker pull $CI_REGISTRY_IMAGE:$PARENT_COMMIT-asset-builder || \
  docker pull $CI_REGISTRY_IMAGE:latest-asset-builder || \
  true

docker pull $CI_REGISTRY_IMAGE:$PARENT_COMMIT || \
  docker pull $CI_REGISTRY_IMAGE:latest || \
  true
