Skip to content

Commit a468365

Browse files
committed
ci: add auto approve job in full pipeline
1 parent 5440b90 commit a468365

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

.gitlab-ci.yml

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ stages:
66
- build_nuttx
77
- test_host
88
- test_nuttx
9-
- coverage
9+
- results
1010
- deploy
1111
- pre_release
1212
- release_stage1
@@ -209,8 +209,8 @@ test_idf_examples:
209209
- job: build_linux_armhf
210210
- job: build_linux_arm64
211211

212-
create_coverage_reports:
213-
stage: coverage
212+
create_reports:
213+
stage: results
214214
tags:
215215
- build
216216
artifacts:
@@ -290,6 +290,29 @@ create_coverage_reports:
290290
- python3 tools/list_to_metrics.py --file cov_infos/metrics_input.txt
291291
- lcov_cobertura cov_infos/merged.info -o cov_infos/cobertura.xml
292292

293+
mr_auto_approve:
294+
stage: results
295+
tags:
296+
- build
297+
dependencies:
298+
- pipeline_variables
299+
when: on_success
300+
script:
301+
- >
302+
if [[ -z ${TRIGGERED_BY_GDB_PIPELINE_BRANCH:-} && $CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH != "master" && $CI_FULL_RUN == "1" ]]; then
303+
api_call="https://${CI_SERVER_HOST}:${CI_SERVER_PORT}/api/v4/projects/67/merge_requests?source_branch=${CI_COMMIT_REF_NAME}&state=opened";
304+
echo "${api_call}";
305+
OPEN_MR=$(curl --header "PRIVATE-TOKEN: ${ESPCI_TOKEN}" "${api_call}");
306+
echo $OPEN_MR;
307+
iid=$(echo "$OPEN_MR" | python3 -c "import json; x=json.loads(input()); print(x[0]['iid'] if len(x) and 'iid' in x[0] else 0)");
308+
target=$(echo "$OPEN_MR" | python3 -c "import json; x=json.loads(input()); print(x[0]['target_branch'] if len(x) and 'target_branch' in x[0] else '')");
309+
if [[ $iid != "0" && $target == "master" ]]; then
310+
api_call="https://${CI_SERVER_HOST}:${CI_SERVER_PORT}/api/v4/projects/67/merge_requests/${iid}/approve";
311+
echo "${api_call}";
312+
curl --request POST --header "PRIVATE-TOKEN: ${ESPCI_TOKEN}" "${api_call}";
313+
fi
314+
fi
315+
293316
update_idf_tools:
294317
stage: update_idf_tools
295318
when: manual

0 commit comments

Comments
 (0)