summaryrefslogtreecommitdiff
path: root/scripts/sync-stable-branch.sh
blob: b44bf26a151176377b5f64157117809fb3eddd69 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env bash

# This script triggers a merge train job to sync an EE stable branch to its
# corresponding CE stable branch.

set -e

if [[ "$MERGE_TRAIN_TRIGGER_TOKEN" == '' ]]
then
    echo 'The variable MERGE_TRAIN_TRIGGER_TOKEN must be set to a non-empy value'
    exit 1
fi

if [[ "$MERGE_TRAIN_TRIGGER_URL" == '' ]]
then
    echo 'The variable MERGE_TRAIN_TRIGGER_URL must be set to a non-empy value'
    exit 1
fi

if [[ "$CI_COMMIT_REF_NAME" == '' ]]
then
    echo 'The variable CI_COMMIT_REF_NAME must be set to a non-empy value'
    exit 1
fi

if [[ "$SOURCE_PROJECT" == '' ]]
then
    echo 'The variable SOURCE_PROJECT must be set to a non-empy value'
    exit 1
fi

if [[ "$TARGET_PROJECT" == '' ]]
then
    echo 'The variable TARGET_PROJECT must be set to a non-empy value'
    exit 1
fi

curl -X POST \
    -F token="$MERGE_TRAIN_TRIGGER_TOKEN" \
    -F ref=master \
    -F "variables[MERGE_FOSS]=1" \
    -F "variables[SOURCE_BRANCH]=$CI_COMMIT_REF_NAME" \
    -F "variables[TARGET_BRANCH]=${CI_COMMIT_REF_NAME/-ee/}" \
    -F "variables[SOURCE_PROJECT]=$SOURCE_PROJECT" \
    -F "variables[TARGET_PROJECT]=$TARGET_PROJECT" \
    "$MERGE_TRAIN_TRIGGER_URL"