Skip to content

Commit

Permalink
Merge pull request #2654 from KaiSzuttor/ci_issue
Browse files Browse the repository at this point in the history
Automatic closing of CI created issues part 2
  • Loading branch information
fweik authored Apr 5, 2019
2 parents c80cf9e + f02fd37 commit f9d5035
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
12 changes: 10 additions & 2 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -385,12 +385,20 @@ 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
only:
- python
tags:
- linux
dependencies: []
14 changes: 14 additions & 0 deletions maintainer/gh_close_issue.sh
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion maintainer/gh_create_issue.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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" \
Expand Down

0 comments on commit f9d5035

Please sign in to comment.