diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 423d01502a247bc26146f78f0c9553ea729608e6..44fcb9dc0e94bcb844899146b4550c0868d8c710 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -10,14 +10,23 @@ stages: variables: SECURE_FILES_DOWNLOAD_PATH: '.secure' -get-credentials: +get-cookie: stage: pre-build image: ubuntu:jammy before_script: - - apt-get update && apt-get upgrade -y && apt-get install curl -y + - apt-get update && apt-get upgrade -y && apt-get install curl jq -y script: - echo "Copying secure file with FeBio login ..." - curl --silent "https://gitlab.com/gitlab-org/incubation-engineering/mobile-devops/download-secure-files/-/raw/main/installer" | bash + - export USERNAME=$(grep 'username:' ${SECURE_FILES_DOWNLOAD_PATH}/febio_login.txt | cut -d ':' -f2 | tr -d ' ') + - export PASSWORD=$(grep 'password:' ${SECURE_FILES_DOWNLOAD_PATH}/febio_login.txt | cut -d ':' -f2 | tr -d ' ') + - export ENCODED_USERNAME=$(printf '%s' "${USERNAME}" | jq -sRr @uri) + - export ENCODED_PASSWORD=$(printf '%s' "${PASSWORD}" | jq -sRr @uri) + - curl -c cookies.txt -X POST -d "log=${ENCODED_USERNAME}&pwd=${ENCODED_PASSWORD}&wp-submit=1" "https://febio.org/wp-login.php" -v + artifacts: + paths: + - cookies.txt + expire_in: 5 minutes docker-build: stage: build @@ -25,10 +34,8 @@ docker-build: services: - docker:dind dependencies: - - get-credentials + - get-cookie script: - - export USERNAME=$(grep 'username:' ${SECURE_FILES_DOWNLOAD_PATH}/febio_login.txt | cut -d ':' -f2 | tr -d ' ') - - export PASSWORD=$(grep 'password:' ${SECURE_FILES_DOWNLOAD_PATH}/febio_login.txt | cut -d ':' -f2 | tr -d ' ') - docker pull $CI_REGISTRY_IMAGE:latest || true - docker build --build-arg BUILDKIT_INLINE_CACHE=1 --build-arg USERNAME=${USERNAME} --build-arg PASSWORD=${PASSWORD} --cache-from $CI_REGISTRY_IMAGE:latest --tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA --tag $CI_REGISTRY_IMAGE:latest . - docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA