mirror of https://github.com/1okko/openpilot.git
CI: Post notifications to Discord
This commit is contained in:
parent
0959f34669
commit
e19383d5f0
|
@ -8,11 +8,13 @@ variables:
|
|||
DEV_C3_SOURCE_BRANCH: "master-dev-c3"
|
||||
GIT_CONFIG_USER_EMAIL: "gitlab@pipeline.com"
|
||||
GIT_CONFIG_USER_NAME: "Gitlab Pipeline"
|
||||
PUBLIC_REPO_URL: "https://github.com/sunnyhaibin/sunnypilot"
|
||||
|
||||
stages:
|
||||
- build
|
||||
- commit_changes
|
||||
- publish
|
||||
- notify
|
||||
|
||||
default:
|
||||
retry: 2
|
||||
|
@ -176,3 +178,40 @@ publish to github:
|
|||
- if: $NEW_BRANCH
|
||||
when: manual
|
||||
- when: never
|
||||
|
||||
.notify_discord: ¬ify_discord
|
||||
stage: notify
|
||||
needs: ["build"]
|
||||
variables:
|
||||
DISCORD_HOOK: "${DISCORD_MANUAL_BUILD_WEBHOOK_URL}" # Default hook if not overriden by children
|
||||
before_script:
|
||||
- 'apk add curl jq envsubst'
|
||||
script:
|
||||
- echo using [${TEMPLATE}]
|
||||
- cat release/ci/${TEMPLATE} | envsubst | tee payload.json
|
||||
- 'curl -X POST -H "Content-Type: application/json" -d "$(cat payload.json)" ${DISCORD_HOOK} | jq .'
|
||||
rules:
|
||||
- if: $NEW_BRANCH
|
||||
when: on_success
|
||||
- when: never
|
||||
allow_failure: true
|
||||
|
||||
notify pending action:
|
||||
extends: ".notify_discord"
|
||||
variables:
|
||||
TEMPLATE: "discord_template_notify_dev_private.json"
|
||||
before_script:
|
||||
- !reference [".notify_discord", "before_script"]
|
||||
- export AVATAR_URL=$(curl -s -X GET "https://gitlab.com/api/v4/avatar?email=${GITLAB_USER_EMAIL}" | jq -r '.avatar_url')
|
||||
|
||||
notify new dev build:
|
||||
extends: ".notify_discord"
|
||||
stage: notify
|
||||
needs: ["publish to github"] # This notify shall only happen after a publish to github public
|
||||
variables:
|
||||
TEMPLATE: "discord_template_notify_dev_public.json"
|
||||
rules:
|
||||
- if: $NEW_BRANCH == "dev-c3"
|
||||
variables:
|
||||
DISCORD_HOOK: "${DISCORD_NEW_BUILD_WEBHOOK_URL}" # Overriding hook because we know we are dev-c3
|
||||
- !reference [".notify_discord", "rules"]
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"embeds": [
|
||||
{
|
||||
"title": "❗️ Action Required for `${CI_COMMIT_REF_NAME}` ❗️",
|
||||
"description": "[${CI_PROJECT_NAME}](${CI_PROJECT_URL}): Pipeline [#${CI_PIPELINE_ID}](${CI_PROJECT_URL}/-/pipelines/${CI_PIPELINE_ID}) of branch [${CI_COMMIT_REF_NAME}](${CI_PROJECT_URL}/-/commits/${CI_COMMIT_REF_NAME}) by ${GITLAB_USER_NAME} (${GITLAB_USER_LOGIN}) is ready to publish manually as [${NEW_BRANCH}](${PUBLIC_REPO_URL}/tree/${NEW_BRANCH})",
|
||||
"color": 16763904,
|
||||
"author": {
|
||||
"name": "${GITLAB_USER_LOGIN}",
|
||||
"icon_url": "${AVATAR_URL}"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"embeds": [
|
||||
{
|
||||
"title": "🎉 sunnypilot `${NEW_BRANCH}` New Update 🎉",
|
||||
"description": "[sunnypilot](${PUBLIC_REPO_URL}): Build #${CI_PIPELINE_IID} of branch [${NEW_BRANCH}](${PUBLIC_REPO_URL}/tree/${NEW_BRANCH}) has been published.\n\nDrive safe! 🚗💨",
|
||||
"color": 4321431
|
||||
}
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue