feat(build): github status jobs
This commit is contained in:
parent
4d19546c95
commit
d76672b9bd
|
@ -1,6 +1,8 @@
|
||||||
stages:
|
stages:
|
||||||
|
- status-pre
|
||||||
- build
|
- build
|
||||||
- image
|
- image
|
||||||
|
- status-post
|
||||||
|
|
||||||
build-go:
|
build-go:
|
||||||
stage: build
|
stage: build
|
||||||
|
@ -48,3 +50,27 @@ build-image:
|
||||||
variables:
|
variables:
|
||||||
DOCKER_DRIVER: overlay2
|
DOCKER_DRIVER: overlay2
|
||||||
DOCKER_HOST: tcp://localhost:237
|
DOCKER_HOST: tcp://localhost:237
|
||||||
|
|
||||||
|
|
||||||
|
github-pending:
|
||||||
|
stage: status-pre
|
||||||
|
extends:
|
||||||
|
- .build-base
|
||||||
|
script:
|
||||||
|
- ./scripts/github-status.sh pending
|
||||||
|
|
||||||
|
github-failure:
|
||||||
|
stage: status-post
|
||||||
|
extends:
|
||||||
|
- .build-base
|
||||||
|
when: on_failure
|
||||||
|
script:
|
||||||
|
- ./scripts/github-status.sh failure
|
||||||
|
|
||||||
|
github-success:
|
||||||
|
stage: status-post
|
||||||
|
extends:
|
||||||
|
- .build-base
|
||||||
|
when: on_success
|
||||||
|
script:
|
||||||
|
- ./scripts/github-status.sh success
|
||||||
|
|
|
@ -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}"
|
Loading…
Reference in New Issue