2019-12-16 10:07:39 -05:00
|
|
|
# Builds a cached .tar.gz of the master branch with full history and
|
|
|
|
# uploads it to Google Cloud Storage. This archive is downloaded by a
|
|
|
|
# script defined by a CI/CD variable named CI_PRE_CLONE_SCRIPT. This has
|
|
|
|
# two benefits:
|
|
|
|
#
|
|
|
|
# 1. It speeds up builds. A 800 MB download only takes seconds.
|
|
|
|
# 2. It significantly reduces load on the file server. Smaller deltas
|
|
|
|
# means less time spent in git pack-objects.
|
|
|
|
#
|
|
|
|
# Since the destination directory of the archive depends on the project
|
|
|
|
# ID, this is only run on GitLab.com.
|
|
|
|
#
|
|
|
|
# CI_REPO_CACHE_CREDENTIALS contains the Google Cloud service account
|
|
|
|
# JSON for uploading to the gitlab-ci-git-repo-cache bucket. These
|
|
|
|
# credentials are stored in the Production vault.
|
|
|
|
#
|
|
|
|
# Note that this bucket should be located in the same continent as the
|
|
|
|
# runner, or network egress charges will apply:
|
|
|
|
# https://cloud.google.com/storage/pricing
|
|
|
|
cache-repo:
|
2020-02-18 10:08:51 -05:00
|
|
|
extends: .cache-repo:rules
|
2019-12-16 10:07:39 -05:00
|
|
|
image: gcr.io/google.com/cloudsdktool/cloud-sdk:alpine
|
|
|
|
stage: sync
|
|
|
|
allow_failure: true
|
|
|
|
variables:
|
2019-12-23 10:07:48 -05:00
|
|
|
GIT_STRATEGY: none
|
2019-12-16 10:07:39 -05:00
|
|
|
TAR_FILENAME: /tmp/gitlab-master.tar
|
|
|
|
script:
|
2019-12-23 10:07:48 -05:00
|
|
|
- cd ..
|
|
|
|
- rm -rf $CI_PROJECT_NAME
|
|
|
|
- git clone --progress $CI_REPOSITORY_URL $CI_PROJECT_NAME
|
|
|
|
- cd $CI_PROJECT_NAME
|
2019-12-16 10:07:39 -05:00
|
|
|
- gcloud auth activate-service-account --key-file=$CI_REPO_CACHE_CREDENTIALS
|
2020-02-08 01:08:50 -05:00
|
|
|
- git remote rm origin
|
2019-12-16 10:07:39 -05:00
|
|
|
- tar cf $TAR_FILENAME .
|
|
|
|
- gzip $TAR_FILENAME
|
|
|
|
- gsutil cp $TAR_FILENAME.gz gs://gitlab-ci-git-repo-cache/project-$CI_PROJECT_ID/gitlab-master.tar.gz
|