summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarin Jankovski <maxlazio@gmail.com>2019-07-04 15:32:06 +0200
committerMarin Jankovski <maxlazio@gmail.com>2019-07-04 15:38:36 +0200
commitc691df241597f32b7efc243859381677069c83df (patch)
tree50fe09c5d482c9afca3bcfbb6a99172be2fa4754
parent000f7ed71f3a87c1361b9a64c1fd7f6a54666392 (diff)
downloadgitlab-ce-c691df241597f32b7efc243859381677069c83df.tar.gz
Syncing to the FOSS repo from a single codebase
-rw-r--r--.gitlab-ci.yml1
-rw-r--r--.gitlab/ci/foss-sync.gitlab-ci.yml9
-rwxr-xr-xscripts/foss-sync.sh60
3 files changed, 70 insertions, 0 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 5b39304444c..1bea63fffac 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -33,6 +33,7 @@ stages:
include:
- local: .gitlab/ci/global.gitlab-ci.yml
+ - local: .gitlab/ci/foss-sync.gitlab-ci.yml
- local: .gitlab/ci/cng.gitlab-ci.yml
- local: .gitlab/ci/docs.gitlab-ci.yml
- local: .gitlab/ci/frontend.gitlab-ci.yml
diff --git a/.gitlab/ci/foss-sync.gitlab-ci.yml b/.gitlab/ci/foss-sync.gitlab-ci.yml
new file mode 100644
index 00000000000..d2edd0d7775
--- /dev/null
+++ b/.gitlab/ci/foss-sync.gitlab-ci.yml
@@ -0,0 +1,9 @@
+codebase:
+ extends: .dedicated-runner
+ stage: prepare
+ before_script: []
+ script:
+ - scripts/foss-sync.sh
+ only:
+# TODO, replace with master@gitlab-org/gitlab-ee
+ - master@marin/gitlab-ee
diff --git a/scripts/foss-sync.sh b/scripts/foss-sync.sh
new file mode 100755
index 00000000000..dbb9593be17
--- /dev/null
+++ b/scripts/foss-sync.sh
@@ -0,0 +1,60 @@
+#!/bin/bash
+
+# TODO, replace with a new repository
+readonly FOSS_REPOSITORY="https://gitlab.com/marin/gitlab-ce.git"
+
+# TODO, replace with a correct bot user
+function git_config_user() {
+ git config --global user.email "marin+release-tools@gitlab.com"
+ git config --global user.name "GitLab Release Tools Bot"
+}
+
+# Backstop 1: Use a global specific git ignore file
+# In the global git ignore file specify that all directories (and files) in the
+# root named "ee" cannot get commited
+function git_config_exclude() {
+ echo "ee/*" >> /tmp/ignore
+ git config --global --add core.excludesFile '/tmp/ignore'
+}
+
+# Use HTTPS clone to avoid dealing with SSH keys
+function git_credentials() {
+ echo "https://$USERNAME:$TOKEN@gitlab.com" > ~/.git-credentials
+ git config --global credential.helper store
+}
+
+# Clone only master of the FOSS repository since that is the only branch we are
+# going to commit to
+function git_clone_foss() {
+ git clone --single-branch --branch "master" $FOSS_REPOSITORY /tmp/gitlab-foss
+}
+
+# Remove the ee directory from the current gitlab(-ee) repository
+# Also remove .git directory to ensure that we don't commit EE history
+function remove_ee_files() {
+ rm -rf .git ee/
+}
+
+function copy_new_files() {
+ cp -rf * /tmp/gitlab-foss/
+}
+
+function foss_commit() {
+ cd /tmp/gitlab-foss
+ git add --all
+ git commit --allow-empty -m "Automatic sync `date +'%Y-%m-%d %H:%M:%S'`"
+ git push origin master
+}
+
+if [[ -z "$CI" ]]; then
+ echo "Not running in CI, nothing to do"
+ exit 0
+else
+ git_config_user
+ git_credentials
+ git_config_exclude
+ git_clone_foss
+ remove_ee_files
+ copy_new_files
+ foss_commit
+fi