Skip to content

Commit

Permalink
feat(build): add github status jobs (fixes #28)
Browse files Browse the repository at this point in the history
  • Loading branch information
ssube committed Jan 11, 2023
1 parent 8452b73 commit c8b2abc
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
26 changes: 26 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ build-gui-bundle:
- cd gui
- make ci

# packages, various
.package-api-oci:
extends:
- .build-oci
Expand Down Expand Up @@ -146,6 +147,7 @@ package-gui-oci-node-buster:
IMAGE_ARCH: node-buster
IMAGE_FILE: Containerfile.node.buster

# language-specific packages
package-api-twine:
extends:
- .build-node
Expand All @@ -171,3 +173,27 @@ package-gui-npm:
script:
- cd gui
- npm publish

# commit status
github-pending:
stage: status-pre
extends:
- .build-curl
script:
- ./common/scripts/github-status.sh pending

github-failure:
stage: status-post
extends:
- .build-curl
when: on_failure
script:
- ./common/scripts/github-status.sh failure

github-success:
stage: status-post
extends:
- .build-curl
when: on_success
script:
- ./common/scripts/github-status.sh success
19 changes: 19 additions & 0 deletions common/scripts/github-status.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#! /bin/sh

STATUS="${1}"
CI_COMMIT_SHA="${CI_COMMIT_SHA:-$(git rev-parse HEAD)}"

STATUS_BODY="$(cat <<EOF
{
"state": "${STATUS}",
"target_url": "${CI_PIPELINE_URL}",
"description": "CI pipeline ${STATUS}!",
"context": "gitlab/build"
}
EOF
)"

printf "Reporting status for %s...\n%s" "${CI_COMMIT_SHA}" "${STATUS_BODY}"
printf "%s" "${STATUS_BODY}" | curl -d @- \
-H "Authorization: token $(printf "%s" "${GITHUB_SECRET}" | base64 -d)" \
-i "https://api.github.com/repos/${CI_PROJECT_PATH}/statuses/${CI_COMMIT_SHA}"

0 comments on commit c8b2abc

Please sign in to comment.