mirror of
https://github.com/sudoxnym/fdroiddata.git
synced 2026-05-20 20:59:11 +00:00
gitlab-ci: improve issuebot trigger for merge requests
This should hopefully provide reliable triggering for issuebot on merge requests. Before, detecting the merge request number was happening on the receiving side, and it had weird issues.
This commit is contained in:
parent
1b9f9f4f8d
commit
979d42858e
2 changed files with 37 additions and 2 deletions
|
|
@ -7,7 +7,6 @@ lint:
|
|||
- schedules
|
||||
- pipelines
|
||||
before_script:
|
||||
- ./tools/trigger-issuebot
|
||||
- printf "Package\x3a androguard fdroidserver python3-asn1crypto python3-ruamel.yaml\nPin\x3a release a=stretch-backports\nPin-Priority\x3a 500\n" > /etc/apt/preferences.d/debian-stretch-backports.pref
|
||||
- echo "deb http://deb.debian.org/debian/ stretch-backports main" > /etc/apt/sources.list.d/backports.list
|
||||
- apt-get update
|
||||
|
|
@ -59,6 +58,18 @@ lint:
|
|||
- ./tools/check-metadata-summary-whitespace.py || export EXITVALUE=1
|
||||
- exit $EXITVALUE
|
||||
|
||||
trigger-issuebot:
|
||||
image: alpine
|
||||
only:
|
||||
- branches
|
||||
except:
|
||||
- master@fdroid/fdroiddata
|
||||
variables:
|
||||
GIT_DEPTH: "1"
|
||||
script:
|
||||
- apk add --no-cache bash curl
|
||||
- ./tools/trigger-issuebot
|
||||
|
||||
checkupdates_trigger:
|
||||
only:
|
||||
refs:
|
||||
|
|
@ -176,6 +187,9 @@ pages:
|
|||
- repo/index.xml
|
||||
- tmp/apkcache.json
|
||||
when: always
|
||||
# needs lots of git history since it has to compare the merge request to current master
|
||||
variables:
|
||||
GIT_DEPTH: "5000"
|
||||
script:
|
||||
- apt-get update
|
||||
- apt-get dist-upgrade
|
||||
|
|
|
|||
|
|
@ -1,9 +1,29 @@
|
|||
#!/bin/bash -e
|
||||
|
||||
get_merge_request_iid() {
|
||||
for page in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19; do
|
||||
for mr in `curl --silent ${CI_API_V4_URL}/projects/${project_id}/merge_requests?page=${page} | grep -Eo '"iid": *[0-9]+' | grep -Eo '[0-9]+$'`; do
|
||||
if curl --silent ${CI_API_V4_URL}/projects/${project_id}/merge_requests/$mr/pipelines \
|
||||
| grep -Eo "\"id\": *${CI_PIPELINE_ID}," > /dev/null; then
|
||||
echo $mr
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
# insecure "captcha"
|
||||
s=$((4`printf "$CI_COMMIT_SHA" | wc -c`-10))
|
||||
e=$((s+`echo "$CI_SERVER_HOST" | wc -c`+18))
|
||||
issuebot=`cat .issuebot | cut -b${s}-${e}`
|
||||
project_id=36528
|
||||
CI_MERGE_REQUEST_IID=`get_merge_request_iid`
|
||||
|
||||
if test -z "$CI_MERGE_REQUEST_IID"; then
|
||||
echo "$0 No merge request found, not triggering"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
curl --silent --request POST \
|
||||
--form token=$issuebot \
|
||||
--form ref=master \
|
||||
|
|
@ -11,8 +31,9 @@ curl --silent --request POST \
|
|||
--form "variables[FROM_CI_COMMIT_REF_SLUG]=$CI_COMMIT_REF_SLUG" \
|
||||
--form "variables[FROM_CI_COMMIT_SHA]=$CI_COMMIT_SHA" \
|
||||
--form "variables[FROM_CI_JOB_ID]=$CI_JOB_ID" \
|
||||
--form "variables[FROM_CI_MERGE_REQUEST_IID]=$CI_MERGE_REQUEST_IID" \
|
||||
--form "variables[FROM_CI_PIPELINE_ID]=$CI_PIPELINE_ID" \
|
||||
--form "variables[FROM_CI_PROJECT_PATH]=$CI_PROJECT_PATH" \
|
||||
--form "variables[FROM_CI_PROJECT_URL]=$CI_PROJECT_URL" \
|
||||
${CI_API_V4_URL}/projects/36528/trigger/pipeline > /dev/null \
|
||||
${CI_API_V4_URL}/projects/${project_id}/trigger/pipeline > /dev/null \
|
||||
|| echo "$0 failed to post to a merge request"
|
||||
|
|
|
|||
Loading…
Reference in a new issue