2021-07-05 14:58:55 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
## push Push changes to Spacemacs bot account.
|
|
|
|
##
|
|
|
|
## Copyright (c) 2014-2021 Sylvain Benner & Contributors
|
|
|
|
##
|
|
|
|
## Author: Eugene Yaremenko
|
|
|
|
## URL: https://github.com/syl20bnr/spacemacs
|
|
|
|
##
|
|
|
|
## This file is not part of GNU Emacs.
|
|
|
|
##
|
|
|
|
## License: GPLv3
|
|
|
|
|
2021-08-01 20:34:01 +00:00
|
|
|
exit_if_no_patchfile
|
2021-07-05 23:45:49 +00:00
|
|
|
|
2021-07-05 22:43:19 +00:00
|
|
|
cd "/tmp/${PUBLISH}"
|
|
|
|
|
2021-07-05 14:58:55 +00:00
|
|
|
echo_headline "Creating fork under bot account"
|
|
|
|
export GITHUB_TOKEN=$UPD_BOT_GIT_TK
|
2021-07-05 22:08:23 +00:00
|
|
|
git checkout -b "${PUBLISH}"
|
2021-07-05 14:58:55 +00:00
|
|
|
hub fork
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "hub fork failed"
|
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
fork_url="https://${UPD_BOT_LOGIN}:${UPD_BOT_GIT_TK}"
|
|
|
|
fork_url+="@github.com/${UPD_BOT_LOGIN}/${UPD_BOT_REPO}.git"
|
|
|
|
git remote set-url "${UPD_BOT_LOGIN}" "${fork_url}"
|
|
|
|
echo_headline "Pushing changes"
|
2021-07-12 15:08:20 +00:00
|
|
|
# hub push -f "${UPD_BOT_LOGIN}" "${PUBLISH}" > /dev/null 2>&1
|
2021-07-07 12:02:39 +00:00
|
|
|
# prevents token leak ^^^^^^^^^^^^^^
|
2021-07-12 15:08:20 +00:00
|
|
|
# NOTE: CircleCI masks environment variables from web GUI thingy
|
|
|
|
# so in this case bot token shouldn't leak. But be careful.
|
|
|
|
# I had to unmask the command output because it's too hard to debug
|
|
|
|
# without logs - a lot of different things may fail.
|
2021-07-12 15:20:30 +00:00
|
|
|
hub push -f "${UPD_BOT_LOGIN}" "${PUBLISH}"
|
2021-07-05 14:58:55 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "hub push failed"
|
|
|
|
exit 2
|
|
|
|
fi
|