diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9eb6e002f2b..719d6d53c9d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -385,7 +385,16 @@ status_failure: - linux dependencies: [] -notify: +notify_success: + stage: result + script: bash maintainer/gh_close_issue.sh + when: on_success + only: + - python + tags: + - linux + +notify_failure: stage: result script: bash maintainer/gh_create_issue.sh when: on_failure @@ -393,4 +402,3 @@ notify: - python tags: - linux - dependencies: [] diff --git a/maintainer/gh_close_issue.sh b/maintainer/gh_close_issue.sh new file mode 100755 index 00000000000..9b5bbac254e --- /dev/null +++ b/maintainer/gh_close_issue.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +ISSUE_NUMBER=$(curl -s -G https://api.github.com/search/issues \ + --data-urlencode "q=\"CI failed for merged PR\" org:espressomd repo:espresso is:open is:issue in:title" \ + --data-urlencode "q=${CI_PIPELINE_ID} org:espressomd repo:espresso is:open is:issue in:body" | jq '.items[0] .number') + +if [ "$ISSUE_NUMBER" != "null" ]; then +curl -s "https://api.github.com/repos/espressomd/espresso/issues/$ISSUE_NUMBER" \ + -H "Accept: application/vnd.github.full+json" \ + -H "Content-Type: application/json" \ + -H "Authorization: token $GITHUB_TOKEN" \ + -X PATCH \ + -d "{\"state\": \"closed\" }" +fi diff --git a/maintainer/gh_create_issue.sh b/maintainer/gh_create_issue.sh index 3c3082ba66e..23cba531edb 100755 --- a/maintainer/gh_create_issue.sh +++ b/maintainer/gh_create_issue.sh @@ -2,7 +2,7 @@ URL=$(echo "https://gitlab.icp.uni-stuttgart.de/espressomd/espresso/pipelines/${CI_PIPELINE_ID}") -curl -i -s "https://api.github.com/repos/espressomd/espresso/issues" \ +curl -s "https://api.github.com/repos/espressomd/espresso/issues" \ -H "Accept: application/vnd.github.full+json" \ -H "Content-Type: application/json" \ -H "Authorization: token $GITHUB_TOKEN" \