Skip to content

Commit 04bb127

Browse files
authored
Merge pull request SvanBoxel#9 from niem94/patch-1
Should fix namespace issue.
2 parents 0d93bd1 + f8d4a7f commit 04bb127

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

entrypoint.sh

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,30 @@
11
#!/bin/sh
22

33
set -u
4+
##################################################################
5+
urlencode() (
6+
i=1
7+
max_i=${#1}
8+
while test $i -le $max_i; do
9+
c="$(expr substr $1 $i 1)"
10+
case $c in
11+
[a-zA-Z0-9.~_-])
12+
printf "$c" ;;
13+
*)
14+
printf '%%%02X' "'$c" ;;
15+
esac
16+
i=$(( i + 1 ))
17+
done
18+
)
419

20+
##################################################################
521
DEFAULT_POLL_TIMEOUT=10
622
POLL_TIMEOUT=${POLL_TIMEOUT:-$DEFAULT_POLL_TIMEOUT}
723

824
git checkout "${GITHUB_REF:11}"
925

10-
branch=${GITHUB_REPOSITORY}/$(git symbolic-ref --short HEAD)
26+
branch="$(git symbolic-ref --short HEAD)"
27+
branch_uri="$(urlencode ${branch})"
1128

1229
sh -c "git config --global credential.username $GITLAB_USERNAME"
1330
sh -c "git config --global core.askPass /cred-helper.sh"
@@ -18,10 +35,7 @@ sh -c "git push mirror $branch"
1835

1936
sleep $POLL_TIMEOUT
2037

21-
# convert slashes in a HTML-compatible way
22-
branch=${branch//\//%2F}
23-
24-
pipeline_id=$(curl --header "PRIVATE-TOKEN: $GITLAB_PASSWORD" --silent "https://${GITLAB_HOSTNAME}/api/v4/projects/${GITLAB_PROJECT_ID}/repository/commits/${branch}" | jq '.last_pipeline.id')
38+
pipeline_id=$(curl --header "PRIVATE-TOKEN: $GITLAB_PASSWORD" --silent "https://${GITLAB_HOSTNAME}/api/v4/projects/${GITLAB_PROJECT_ID}/repository/commits/${branch_uri}" | jq '.last_pipeline.id')
2539

2640
echo "Triggered CI for branch ${branch}"
2741
echo "Working with pipeline id #${pipeline_id}"

0 commit comments

Comments
 (0)