From 52611813ba1aa04d5f7c204f7bdb1329ce1593b5 Mon Sep 17 00:00:00 2001
From: Wouter Deconinck <wdconinc@gmail.com>
Date: Mon, 1 Aug 2022 00:55:03 +0000
Subject: [PATCH] fix: send status updates to github

---
 .gitlab-ci.yml | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index dd72a94a..7527eb75 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -26,6 +26,7 @@ default:
       dotenv: juggler.env
 
 stages:
+  - status-pending
   - config
   - initialize
   - data_init
@@ -35,6 +36,24 @@ stages:
   - collect
   - deploy
   - trigger
+  - status-success
+
+benchmarks:detector:pending:
+  stage: status-pending
+  script:
+    - |
+      if [ -n "${GITHUB_SHA}" ] ; then
+        curl \
+          -X POST \
+          -H "Accept: application/vnd.github+json" \ 
+          -H "Authorization: token ${GITHUB_REPO_STATUS_TOKEN}" \
+          https://api.github.com/repos/${GITHUB_REPOSITORY}/statuses/${GITHUB_SHA} \
+          -d '{"state":"pending", \
+               "target_url":"${CI_PIPELINE_URL}", \
+               "description":"The detector benchmarks are running...", \
+               "context":"eicweb/detector_benchmarks" \
+               }' ;
+      fi
 
 common:setup:
   stage: config
@@ -132,6 +151,25 @@ deploy_results:
   script:
     - echo "deploy results!"
 
+benchmarks:detector:success:
+  stage: status-success
+  needs:
+    - ["deploy_results"]
+  script:
+    - |
+      if [ -n "${GITHUB_SHA}" ] ; then
+        curl \
+          -X POST \
+          -H "Accept: application/vnd.github+json" \ 
+          -H "Authorization: token ${GITHUB_REPO_STATUS_TOKEN}" \
+          https://api.github.com/repos/${GITHUB_REPOSITORY}/statuses/${GITHUB_SHA} \
+          -d '{"state":"success", \
+               "target_url":"${CI_PIPELINE_URL}", \
+               "description":"The detector benchmarks succeeded!", \
+               "context":"eicweb/detector_benchmarks" \
+               }' ;
+      fi
+
 benchmarks:reconstruction:
   stage: trigger
   variables:
-- 
GitLab