forked from Hostea/website
fix: set SSH remote in CI
parent
023cd1dcc3
commit
4919f78d10
|
@ -8,4 +8,4 @@ pipeline:
|
|||
- make
|
||||
- ls -lah && find scripts && cat scripts/ci.sh
|
||||
- make ci-deploy
|
||||
secrets: [ pages_deploy_secret, hostea_write_deploy_key]
|
||||
secrets: [ pages_deploy_secret, hostea_write_deploy_key ]
|
||||
|
|
|
@ -15,10 +15,11 @@
|
|||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
set -xEeuo pipefail
|
||||
set -xEeuo pipefail
|
||||
#source $(pwd)/scripts/lib.sh
|
||||
|
||||
readonly SSH_ID_FILE=/tmp/ci-ssh-id
|
||||
readonly SSH_REMOTE_NAME=origin-ssh
|
||||
|
||||
match_arg() {
|
||||
if [ $1 == $2 ] || [ $1 == $3 ]
|
||||
|
@ -48,6 +49,15 @@ write_ssh(){
|
|||
echo $1 > $SSH_ID_FILE
|
||||
}
|
||||
|
||||
set_ssh_remote() {
|
||||
http_remote_url=$(git remote get-url origin)
|
||||
remote_hostname=$(echo $http_remote_url | cut -d '/' -f 3)
|
||||
repository_owner=$(echo $http_remote_url | cut -d '/' -f 4)
|
||||
repository_name=$(echo $http_remote_url | cut -d '/' -f 5)
|
||||
ssh_remote="git@$remote_hostname:$repository_owner/$repository_name"
|
||||
git remote add $SSH_REMOTE_NAME $ssh_remote || true
|
||||
}
|
||||
|
||||
clean() {
|
||||
if [ -f $SSH_ID_FILE ]
|
||||
then
|
||||
|
@ -63,7 +73,7 @@ deploy() {
|
|||
then
|
||||
help
|
||||
else
|
||||
git -c core.sshCommand="/usr/bin/ssh -i $SSH_ID_FILE" push origin $2
|
||||
git -c core.sshCommand="/usr/bin/ssh -i $SSH_ID_FILE" push $SSH_REMOTE_NAME $2
|
||||
curl -vv --location --request \
|
||||
POST "https://hostea.org:5000/api/v1/update"\
|
||||
--header 'Content-Type: application/json' \
|
||||
|
@ -87,6 +97,7 @@ then
|
|||
help
|
||||
exit -1
|
||||
fi
|
||||
set_ssh_remote
|
||||
write_ssh $2
|
||||
elif match_arg $1 '-c' '--clean'
|
||||
then
|
||||
|
|
Loading…
Reference in New Issue