-
Notifications
You must be signed in to change notification settings - Fork 0
/
submit
executable file
·37 lines (34 loc) · 979 Bytes
/
submit
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
#!/usr/bin/env bash
if [[ -z "${ACADEMY_EDITABLE}" ]]; then
echo "Missing ACADEMY_EDITABLE variable"
exit 1
fi
if [[ -z "${ACADEMY_SUBMIT_TOKEN}" ]]; then
echo "Missing ACADEMY_SUBMIT_TOKEN variable or token"
exit 1
fi
# set url with token
declare git_url
git_url="https://project_${CI_PROJECT_ID}_bot:${ACADEMY_SUBMIT_TOKEN}@${CI_SERVER_HOST}/${CI_PROJECT_PATH}.git"
git remote set-url origin "${git_url}"
# update current repo
git pull origin main:main
git fetch origin source:source
git fetch origin submit:submit
# reset possible mess
git reset --hard
git clean -fd
# update from source
git checkout submit
git merge --no-ff --strategy-option theirs source
# copy editable files from main
# shellcheck disable=SC2086
rm ${ACADEMY_EDITABLE}
# shellcheck disable=SC2086
git checkout main -- ${ACADEMY_EDITABLE} 2>/dev/null
# rm .results (clean mess)
rm -rf .results/
# push to submit
git add .
git commit -am "Sync with source and main"
git push "${git_url}" submit