Skip to content

Commit b57d548

Browse files
committed
Merge upstream branch 'master'
2 parents 8181c09 + 04bb127 commit b57d548

File tree

2 files changed

+21
-12
lines changed

2 files changed

+21
-12
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ jobs:
2626
GITLAB_HOSTNAME: "gitlab.com"
2727
GITLAB_USERNAME: "svboxel"
2828
GITLAB_PASSWORD: ${{ secrets.GITLAB_PASSWORD }} // Generate here: https://gitlab.com/profile/personal_access_tokens
29-
GITLAB_PROJECT_ID: "<GitLab project ID>"
30-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} // https://help.github.com/en/articles/virtual-environments-for-github-actions#github_token-secret
29+
GITLAB_PROJECT_ID: "<GitLab project ID>" // https://gitlab.com/<namespace>/<repository>/edit
30+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} // https://docs.github.com/en/actions/reference/authentication-in-a-workflow#about-the-github_token-secret
3131
```
3232

3333
Be sure to define the `GITLAB_PASSWORD` secret in `https://github.com/<namespace>/<repository>/settings/secrets`

entrypoint.sh

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +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-
if [ "$GITLAB_HOSTNAME" = "gitlab.com" ]
11-
then
12-
branch=${GITHUB_REPOSITORY}/$(git symbolic-ref --short HEAD)
13-
else
14-
branch=$(git symbolic-ref --short HEAD)
15-
fi
26+
branch="$(git symbolic-ref --short HEAD)"
27+
branch_uri="$(urlencode ${branch})"
1628

1729
sh -c "git config --global credential.username $GITLAB_USERNAME"
1830
sh -c "git config --global core.askPass /cred-helper.sh"
@@ -23,10 +35,7 @@ sh -c "git push mirror $branch"
2335

2436
sleep $POLL_TIMEOUT
2537

26-
# convert slashes in a HTML-compatible way
27-
branch=${branch//\//%2F}
28-
29-
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')
3039

3140
echo "Triggered CI for branch ${branch}"
3241
echo "Working with pipeline id #${pipeline_id}"

0 commit comments

Comments
 (0)