94 lines
3.6 KiB
YAML
94 lines
3.6 KiB
YAML
kind: pipeline
|
|
type: kubernetes
|
|
name: modules-php-sat-client
|
|
|
|
clone:
|
|
depth: 1
|
|
|
|
steps:
|
|
- name: tests
|
|
image: composer:latest
|
|
pull: always
|
|
commands:
|
|
- composer install
|
|
- composer test
|
|
when:
|
|
branch:
|
|
- main
|
|
- prod
|
|
|
|
- name: building
|
|
image: alpine
|
|
commands:
|
|
- apk add zip
|
|
- zip -r package.zip src composer.json README.md
|
|
when:
|
|
branch:
|
|
- prod
|
|
|
|
- name: composer-deploy
|
|
image: alpine
|
|
environment:
|
|
REGISTRY_TOKEN:
|
|
from_secret: DRONE_NPM_PUBLISHER_TOKEN
|
|
commands:
|
|
- apk add curl
|
|
- curl --fail-with-body --user modules-communs-php:$REGISTRY_TOKEN --upload-file ./package.zip https://git.nwb.fr/api/packages/modules-communs-php/composer
|
|
when:
|
|
branch:
|
|
- prod
|
|
|
|
- name: google-chat
|
|
image: badouralix/curl-jq
|
|
failure: ignore
|
|
environment:
|
|
GOOGLE_CHAT_WEBHOOK: "https://chat.googleapis.com/v1/spaces/AAQAGPSk8N0/messages?key=AIzaSyDdI0hCZtE6vySjMm-WEfRq3CPzqKqqsHI&token=QA6EDa74Bv-zWs7NiWrq54npANfaUtgqQBjOd35ZRCs"
|
|
NOTIFICATION_CONTEXT: "Build"
|
|
NOTIFICATION_TARGET_LABEL: "Voir le dépôt"
|
|
NOTIFICATION_TARGET_URL: "https://git.nwb.fr/modules-communs-php/multi-downloader-client"
|
|
commands:
|
|
- |
|
|
set -eu
|
|
jq -n '
|
|
def html: gsub("&"; "&") | gsub("<"; "<") | gsub(">"; ">");
|
|
(env.DRONE_BUILD_STATUS == "success") as $success |
|
|
(env.NOTIFICATION_CONTEXT // "Build") as $context |
|
|
{
|
|
cardsV2: [{
|
|
cardId: "drone-notification",
|
|
card: {
|
|
header: {
|
|
title: (if env.NOTIFICATION_PHASE == "start" then "🚀 " + $context + (if $context == "Publication" then " démarrée" else " démarré" end) elif $success then "✅ " + $context + (if $context == "Publication" then " réussie" else " réussi" end) else "❌ " + $context + " en échec" end),
|
|
subtitle: ((env.DRONE_REPO_NAME // "Projet") + " · build #" + (env.DRONE_BUILD_NUMBER // "?"))
|
|
},
|
|
sections: [{
|
|
widgets: [
|
|
{decoratedText: {startIcon: {materialIcon: {name: "person"}}, topLabel: "Auteur", text: ((env.DRONE_COMMIT_AUTHOR_NAME // env.DRONE_COMMIT_AUTHOR // "Inconnu") | html)}},
|
|
{decoratedText: {startIcon: {materialIcon: {name: "account_tree"}}, topLabel: "Branche", text: ((env.DRONE_BRANCH // "Inconnue") | html)}},
|
|
{decoratedText: {startIcon: {materialIcon: {name: "commit"}}, topLabel: "Commit", text: (((env.DRONE_COMMIT_SHA // "")[0:8] + " : " + (env.DRONE_COMMIT_MESSAGE // "")) | html), wrapText: true}},
|
|
{buttonList: {buttons: ([
|
|
{text: env.NOTIFICATION_TARGET_LABEL, onClick: {openLink: {url: env.NOTIFICATION_TARGET_URL}}},
|
|
{text: "Voir les logs Drone", onClick: {openLink: {url: env.DRONE_BUILD_LINK}}},
|
|
{text: "Voir le commit", onClick: {openLink: {url: env.DRONE_COMMIT_LINK}}}
|
|
] | map(select(.onClick.openLink.url != null and .onClick.openLink.url != "")))}}
|
|
]
|
|
}]
|
|
}
|
|
}]
|
|
}
|
|
' > /tmp/google-chat-payload.json
|
|
curl --fail-with-body --silent --show-error --connect-timeout 10 --max-time 30 \
|
|
-X POST -H "Content-Type: application/json; charset=UTF-8" \
|
|
--data-binary @/tmp/google-chat-payload.json "$GOOGLE_CHAT_WEBHOOK"
|
|
when:
|
|
status:
|
|
- failure
|
|
- success
|
|
|
|
trigger:
|
|
branch:
|
|
- main
|
|
- prod
|
|
event:
|
|
- push
|