Final notifications setup

This commit is contained in:
2026-02-12 01:35:22 -03:00
parent fe8cf26a29
commit 7a01cbd2c9
2 changed files with 90 additions and 87 deletions

View File

@@ -28,63 +28,21 @@ steps:
- name: Send Lint Status Notification (failure) - name: Send Lint Status Notification (failure)
image: curlimages/curl image: curlimages/curl
environment: environment:
MATTERMOST_WEBHOOK_URL:
from_secret: mattermost_test_webhook
MATTERMOST_BOT_ACCESS_TOKEN: MATTERMOST_BOT_ACCESS_TOKEN:
from_secret: mattermost_bot_access_token from_secret: mattermost_bot_access_token
MATTERMOST_CHANNEL_ID:
from_secret: MATTERMOST_CHANNEL_ID
MATTERMOST_POST_API_URL:
from_secret: mattermost_post_api_url
commands: commands:
# - |
# BODY=$(printf '{"username":"WoodpeckerBot","text":"[%s - Build #%s] Lint failure 💩"}' "$CI_REPO" "$CI_PIPELINE_NUMBER")
# curl -sS -X POST -H "Content-Type: application/json" -d "$BODY" -H "Authorization: Bearer $MATTERMOST_BOT_ACCESS_TOKEN" "$MATTERMOST_WEBHOOK_URL"
- | - |
BODY=$(printf '{"channel_id":"4qgg5yxg67y85q53syijgj4ase","message":"[%s - Build #%s] Lint failure 💩"}' "$CI_REPO" "$CI_PIPELINE_NUMBER") BODY=$(printf '{"channel_id":"%s","message":"[%s - Build #%s] Lint failure 💩"}' "$MATTERMOST_CHANNEL_ID" "$CI_REPO" "$CI_PIPELINE_NUMBER")
curl -sS -X POST -H "Content-Type: application/json" -d "$BODY" -H "Authorization: Bearer $MATTERMOST_BOT_ACCESS_TOKEN" https://lab.mifi.dev/api/v4/posts curl -sS -X POST -H "Content-Type: application/json" -d "$BODY" -H "Authorization: Bearer $MATTERMOST_BOT_ACCESS_TOKEN" $MATTERMOST_POST_API_URL
depends_on: depends_on:
- lint - lint
when: when:
- status: [failure] - status: [failure]
- name: Send Lint Status Notification (success)
image: curlimages/curl
environment:
MATTERMOST_WEBHOOK_URL:
from_secret: mattermost_test_webhook
MATTERMOST_BOT_ACCESS_TOKEN:
from_secret: mattermost_bot_access_token
commands:
- |
BODY=$(printf '{"channel_id":"4qgg5yxg67y85q53syijgj4ase","message":"[%s - Build #%s] Lint success 🎉"}' "$CI_REPO" "$CI_PIPELINE_NUMBER")
curl -sS -X POST -H "Content-Type: application/json" -d "$BODY" -H "Authorization: Bearer $MATTERMOST_BOT_ACCESS_TOKEN" https://lab.mifi.dev/api/v4/posts
depends_on:
- lint
when:
- status: [success]
- name: build
image: node:20-alpine
commands:
- corepack enable && corepack prepare pnpm@10.28.2 --activate
- pnpm install --frozen-lockfile || pnpm install
- pnpm run build
depends_on:
- install
- name: Send Test Build Status Notification (failure)
image: curlimages/curl
environment:
MATTERMOST_WEBHOOK_URL:
from_secret: mattermost_test_webhook
MATTERMOST_BOT_ACCESS_TOKEN:
from_secret: mattermost_bot_access_token
commands:
- |
BODY=$(printf '{"username":"WoodpeckerBot","text":"[%s - Build #%s] Test build failure 💩"}' "$CI_REPO" "$CI_PIPELINE_NUMBER")
curl -sS -X POST -H "Content-Type: application/json" -d "$BODY" -H "Authorization: Bearer $MATTERMOST_BOT_ACCESS_TOKEN" "$MATTERMOST_WEBHOOK_URL"
depends_on:
- build
when:
- status: [failure]
- name: unit test - name: unit test
image: node:20-alpine image: node:20-alpine
commands: commands:
@@ -93,24 +51,53 @@ steps:
- pnpm exec svelte-kit sync - pnpm exec svelte-kit sync
- pnpm test - pnpm test
depends_on: depends_on:
- install - lint
- name: Send Unit Test Status Notification (failure) - name: Send Unit Test Status Notification (failure)
image: curlimages/curl image: curlimages/curl
environment: environment:
MATTERMOST_WEBHOOK_URL:
from_secret: mattermost_test_webhook
MATTERMOST_BOT_ACCESS_TOKEN: MATTERMOST_BOT_ACCESS_TOKEN:
from_secret: mattermost_bot_access_token from_secret: mattermost_bot_access_token
MATTERMOST_CHANNEL_ID:
from_secret: MATTERMOST_CHANNEL_ID
MATTERMOST_POST_API_URL:
from_secret: mattermost_post_api_url
commands: commands:
- | - |
BODY=$(printf '{"username":"WoodpeckerBot","text":"[%s - Build #%s] Unit test failure 💩"}' "$CI_REPO" "$CI_PIPELINE_NUMBER") BODY=$(printf '{"channel_id":"%s","message":"[%s - Build #%s] Unit test failure 💩"}' "$MATTERMOST_CHANNEL_ID" "$CI_REPO" "$CI_PIPELINE_NUMBER")
curl -sS -X POST -H "Content-Type: application/json" -d "$BODY" -H "Authorization: Bearer $MATTERMOST_BOT_ACCESS_TOKEN" "$MATTERMOST_WEBHOOK_URL" curl -sS -X POST -H "Content-Type: application/json" -d "$BODY" -H "Authorization: Bearer $MATTERMOST_BOT_ACCESS_TOKEN" $MATTERMOST_POST_API_URL
depends_on: depends_on:
- unit test - unit test
when: when:
- status: [failure] - status: [failure]
- name: build
image: node:20-alpine
commands:
- corepack enable && corepack prepare pnpm@10.28.2 --activate
- pnpm install --frozen-lockfile || pnpm install
- pnpm run build
depends_on:
- unit test
- name: Send Test Build Status Notification (failure)
image: curlimages/curl
environment:
MATTERMOST_BOT_ACCESS_TOKEN:
from_secret: mattermost_bot_access_token
MATTERMOST_CHANNEL_ID:
from_secret: MATTERMOST_CHANNEL_ID
MATTERMOST_POST_API_URL:
from_secret: mattermost_post_api_url
commands:
- |
BODY=$(printf '{"channel_id":"%s","message":"[%s - Build #%s] Test build failure 💩"}' "$MATTERMOST_CHANNEL_ID" "$CI_REPO" "$CI_PIPELINE_NUMBER")
curl -sS -X POST -H "Content-Type: application/json" -d "$BODY" -H "Authorization: Bearer $MATTERMOST_BOT_ACCESS_TOKEN" $MATTERMOST_POST_API_URL
depends_on:
- build
when:
- status: [failure]
- name: e2e test - name: e2e test
image: mcr.microsoft.com/playwright:v1.58.0-noble image: mcr.microsoft.com/playwright:v1.58.0-noble
commands: commands:
@@ -121,19 +108,21 @@ steps:
- sleep 2 - sleep 2
- CI=1 pnpm run test:e2e - CI=1 pnpm run test:e2e
depends_on: depends_on:
- unit test - build
- name: Send E2E Test Status Notification (failure) - name: Send E2E Test Status Notification (failure)
image: curlimages/curl image: curlimages/curl
environment: environment:
MATTERMOST_WEBHOOK_URL:
from_secret: mattermost_test_webhook
MATTERMOST_BOT_ACCESS_TOKEN: MATTERMOST_BOT_ACCESS_TOKEN:
from_secret: mattermost_bot_access_token from_secret: mattermost_bot_access_token
MATTERMOST_CHANNEL_ID:
from_secret: MATTERMOST_CHANNEL_ID
MATTERMOST_POST_API_URL:
from_secret: mattermost_post_api_url
commands: commands:
- | - |
BODY=$(printf '{"username":"WoodpeckerBot","text":"[%s - Build #%s] E2E test failure 💩"}' "$CI_REPO" "$CI_PIPELINE_NUMBER") BODY=$(printf '{"channel_id":"%s","message":"[%s - Build #%s] E2E test failure 💩"}' "$MATTERMOST_CHANNEL_ID" "$CI_REPO" "$CI_PIPELINE_NUMBER")
curl -sS -X POST -H "Content-Type: application/json" -d "$BODY" -H "Authorization: Bearer $MATTERMOST_BOT_ACCESS_TOKEN" "$MATTERMOST_WEBHOOK_URL" curl -sS -X POST -H "Content-Type: application/json" -d "$BODY" -H "Authorization: Bearer $MATTERMOST_BOT_ACCESS_TOKEN" $MATTERMOST_POST_API_URL
depends_on: depends_on:
- e2e test - e2e test
when: when:
@@ -142,19 +131,21 @@ steps:
- name: Send CI Pipeline Status Notification (success) - name: Send CI Pipeline Status Notification (success)
image: curlimages/curl image: curlimages/curl
environment: environment:
MATTERMOST_WEBHOOK_URL:
from_secret: mattermost_test_webhook
MATTERMOST_BOT_ACCESS_TOKEN: MATTERMOST_BOT_ACCESS_TOKEN:
from_secret: mattermost_bot_access_token from_secret: mattermost_bot_access_token
MATTERMOST_CHANNEL_ID:
from_secret: MATTERMOST_CHANNEL_ID
MATTERMOST_POST_API_URL:
from_secret: mattermost_post_api_url
commands: commands:
- | - |
BODY=$(printf '{"username":"WoodpeckerBot","text":"[%s - Build #%s] CI pipeline success 🎉"}' "$CI_REPO" "$CI_PIPELINE_NUMBER") BODY=$(printf '{"channel_id":"%s","message":"[%s - Build #%s] CI pipeline success 🎉"}' "$MATTERMOST_CHANNEL_ID" "$CI_REPO" "$CI_PIPELINE_NUMBER")
curl -sS -X POST -H "Content-Type: application/json" -d "$BODY" -H "Authorization: Bearer $MATTERMOST_BOT_ACCESS_TOKEN" "$MATTERMOST_WEBHOOK_URL" curl -sS -X POST -H "Content-Type: application/json" -d "$BODY" -H "Authorization: Bearer $MATTERMOST_BOT_ACCESS_TOKEN" $MATTERMOST_POST_API_URL
depends_on: depends_on:
- install - install
- lint - lint
- build
- unit test - unit test
- build
- e2e test - e2e test
when: when:
- status: [success] - status: [success]

View File

@@ -35,14 +35,16 @@ steps:
- name: Send Build Status Notification (success) - name: Send Build Status Notification (success)
image: curlimages/curl image: curlimages/curl
environment: environment:
MATTERMOST_WEBHOOK_URL:
from_secret: mattermost_deploy_webhook
MATTERMOST_BOT_ACCESS_TOKEN: MATTERMOST_BOT_ACCESS_TOKEN:
from_secret: mattermost_bot_access_token from_secret: mattermost_bot_access_token
MATTERMOST_CHANNEL_ID:
from_secret: mattermost_pushes_channel_id
MATTERMOST_POST_API_URL:
from_secret: mattermost_post_api_url
commands: commands:
- | - |
BODY=$(printf '{"username":"WoodpeckerBot","text":"[%s - Build #%s] Build success 🎉"}' "$CI_REPO" "$CI_PIPELINE_NUMBER") BODY=$(printf '{"channel_id":"%s","message":"[%s - Build #%s] Build success 🎉"}' "$MATTERMOST_CHANNEL_ID" "$CI_REPO" "$CI_PIPELINE_NUMBER")
curl -sS -X POST -H "Content-Type: application/json" -d "$BODY" -H "Authorization: Bearer $MATTERMOST_BOT_ACCESS_TOKEN" "$MATTERMOST_WEBHOOK_URL" curl -sS -X POST -H "Content-Type: application/json" -d "$BODY" -H "Authorization: Bearer $MATTERMOST_BOT_ACCESS_TOKEN" $MATTERMOST_POST_API_URL
depends_on: depends_on:
- 'Docker image build' - 'Docker image build'
when: when:
@@ -51,14 +53,16 @@ steps:
- name: Send Build Status Notification (failure) - name: Send Build Status Notification (failure)
image: curlimages/curl image: curlimages/curl
environment: environment:
MATTERMOST_WEBHOOK_URL:
from_secret: mattermost_deploy_webhook
MATTERMOST_BOT_ACCESS_TOKEN: MATTERMOST_BOT_ACCESS_TOKEN:
from_secret: mattermost_bot_access_token from_secret: mattermost_bot_access_token
MATTERMOST_CHANNEL_ID:
from_secret: mattermost_pushes_channel_id
MATTERMOST_POST_API_URL:
from_secret: mattermost_post_api_url
commands: commands:
- | - |
BODY=$(printf '{"username":"WoodpeckerBot","text":"[%s - Build #%s] Build failure 💩"}' "$CI_REPO" "$CI_PIPELINE_NUMBER") BODY=$(printf '{"channel_id":"%s","message":"[%s - Build #%s] Build failure 💩"}' "$MATTERMOST_CHANNEL_ID" "$CI_REPO" "$CI_PIPELINE_NUMBER")
curl -sS -X POST -H "Content-Type: application/json" -d "$BODY" -H "Authorization: Bearer $MATTERMOST_BOT_ACCESS_TOKEN" "$MATTERMOST_WEBHOOK_URL" curl -sS -X POST -H "Content-Type: application/json" -d "$BODY" -H "Authorization: Bearer $MATTERMOST_BOT_ACCESS_TOKEN" $MATTERMOST_POST_API_URL
depends_on: depends_on:
- Docker image build - Docker image build
when: when:
@@ -94,14 +98,16 @@ steps:
- name: Send Push Status Notification (success) - name: Send Push Status Notification (success)
image: curlimages/curl image: curlimages/curl
environment: environment:
MATTERMOST_WEBHOOK_URL:
from_secret: mattermost_deploy_webhook
MATTERMOST_BOT_ACCESS_TOKEN: MATTERMOST_BOT_ACCESS_TOKEN:
from_secret: mattermost_bot_access_token from_secret: mattermost_bot_access_token
MATTERMOST_CHANNEL_ID:
from_secret: mattermost_pushes_channel_id
MATTERMOST_POST_API_URL:
from_secret: mattermost_post_api_url
commands: commands:
- | - |
BODY=$(printf '{"username":"WoodpeckerBot","text":"[%s - Build #%s] Push to registry success 🎉"}' "$CI_REPO" "$CI_PIPELINE_NUMBER") BODY=$(printf '{"channel_id":"%s","message":"[%s - Build #%s] Push to registry success 🎉"}' "$MATTERMOST_CHANNEL_ID" "$CI_REPO" "$CI_PIPELINE_NUMBER")
curl -sS -X POST -H "Content-Type: application/json" -d "$BODY" -H "Authorization: Bearer $MATTERMOST_BOT_ACCESS_TOKEN" "$MATTERMOST_WEBHOOK_URL" curl -sS -X POST -H "Content-Type: application/json" -d "$BODY" -H "Authorization: Bearer $MATTERMOST_BOT_ACCESS_TOKEN" $MATTERMOST_POST_API_URL
depends_on: depends_on:
- 'Push to registry' - 'Push to registry'
when: when:
@@ -110,14 +116,16 @@ steps:
- name: Send Push Status Notification (failure) - name: Send Push Status Notification (failure)
image: curlimages/curl image: curlimages/curl
environment: environment:
MATTERMOST_WEBHOOK_URL:
from_secret: mattermost_deploy_webhook
MATTERMOST_BOT_ACCESS_TOKEN: MATTERMOST_BOT_ACCESS_TOKEN:
from_secret: mattermost_bot_access_token from_secret: mattermost_bot_access_token
MATTERMOST_CHANNEL_ID:
from_secret: mattermost_pushes_channel_id
MATTERMOST_POST_API_URL:
from_secret: mattermost_post_api_url
commands: commands:
- | - |
BODY=$(printf '{"username":"WoodpeckerBot","text":"[%s - Build #%s] Push to registry failure 💩"}' "$CI_REPO" "$CI_PIPELINE_NUMBER") BODY=$(printf '{"channel_id":"%s","message":"[%s - Build #%s] Push to registry failure 💩"}' "$MATTERMOST_CHANNEL_ID" "$CI_REPO" "$CI_PIPELINE_NUMBER")
curl -sS -X POST -H "Content-Type: application/json" -d "$BODY" -H "Authorization: Bearer $MATTERMOST_BOT_ACCESS_TOKEN" "$MATTERMOST_WEBHOOK_URL" curl -sS -X POST -H "Content-Type: application/json" -d "$BODY" -H "Authorization: Bearer $MATTERMOST_BOT_ACCESS_TOKEN" $MATTERMOST_POST_API_URL
depends_on: depends_on:
- 'Push to registry' - 'Push to registry'
when: when:
@@ -146,14 +154,16 @@ steps:
- name: Send Deploy Status Notification (success) - name: Send Deploy Status Notification (success)
image: curlimages/curl image: curlimages/curl
environment: environment:
MATTERMOST_WEBHOOK_URL:
from_secret: mattermost_deploy_webhook
MATTERMOST_BOT_ACCESS_TOKEN: MATTERMOST_BOT_ACCESS_TOKEN:
from_secret: mattermost_bot_access_token from_secret: mattermost_bot_access_token
MATTERMOST_CHANNEL_ID:
from_secret: mattermost_pushes_channel_id
MATTERMOST_POST_API_URL:
from_secret: mattermost_post_api_url
commands: commands:
- | - |
BODY=$(printf '{"username":"WoodpeckerBot","text":"[%s - Build #%s] Production Deploy success 🎉"}' "$CI_REPO" "$CI_PIPELINE_NUMBER") BODY=$(printf '{"channel_id":"%s","message":"[%s - Build #%s] Production Deploy success 🎉"}' "$MATTERMOST_CHANNEL_ID" "$CI_REPO" "$CI_PIPELINE_NUMBER")
curl -sS -X POST -H "Content-Type: application/json" -d "$BODY" -H "Authorization: Bearer $MATTERMOST_BOT_ACCESS_TOKEN" "$MATTERMOST_WEBHOOK_URL" curl -sS -X POST -H "Content-Type: application/json" -d "$BODY" -H "Authorization: Bearer $MATTERMOST_BOT_ACCESS_TOKEN" $MATTERMOST_POST_API_URL
depends_on: depends_on:
- 'Trigger Portainer stack redeploy' - 'Trigger Portainer stack redeploy'
when: when:
@@ -162,14 +172,16 @@ steps:
- name: Send Deploy Status Notification (failure) - name: Send Deploy Status Notification (failure)
image: curlimages/curl image: curlimages/curl
environment: environment:
MATTERMOST_WEBHOOK_URL:
from_secret: mattermost_deploy_webhook
MATTERMOST_BOT_ACCESS_TOKEN: MATTERMOST_BOT_ACCESS_TOKEN:
from_secret: mattermost_bot_access_token from_secret: mattermost_bot_access_token
MATTERMOST_CHANNEL_ID:
from_secret: mattermost_pushes_channel_id
MATTERMOST_POST_API_URL:
from_secret: mattermost_post_api_url
commands: commands:
- | - |
BODY=$(printf '{"username":"WoodpeckerBot","text":"[%s - Build #%s] Production Deploy failure 💩"}' "$CI_REPO" "$CI_PIPELINE_NUMBER") BODY=$(printf '{"channel_id":"%s","message":"[%s - Build #%s] Production Deploy failure 💩"}' "$MATTERMOST_CHANNEL_ID" "$CI_REPO" "$CI_PIPELINE_NUMBER")
curl -sS -X POST -H "Content-Type: application/json" -d "$BODY" -H "Authorization: Bearer $MATTERMOST_BOT_ACCESS_TOKEN" "$MATTERMOST_WEBHOOK_URL" curl -sS -X POST -H "Content-Type: application/json" -d "$BODY" -H "Authorization: Bearer $MATTERMOST_BOT_ACCESS_TOKEN" $MATTERMOST_POST_API_URL
depends_on: depends_on:
- Trigger Portainer stack redeploy - Trigger Portainer stack redeploy
when: when: