Ontwikkel een GitHub Actions Workflow voor Aangepaste Meldingen en Alerts
description
Maakt real-time, aangepaste communicatie mogelijk over de status van je CI/CD-pijplijn, waardoor teambewustzijn en snelle reactie op build- of deploymentproblemen verbeteren. Deze prompt helpt je om verschillende meldingskanalen te integreren die zijn afgestemd op jouw voorkeuren, waardoor de workflow transparanter wordt dan met standaard GitHub-meldingen.
prompt
Help me een GitHub Actions workflow te ontwerpen die aangepaste meldingen en alerts integreert. Meldingskanalen: <voer je favoriete meldingskanalen in, bijv. Slack, e-mail, Microsoft Teams>. Trigger gebeurtenissen: <specificeer b ...
try_prompt
generate_helper
disclaimerOnPageApi
tags
ai_answers
provider: openai
model: gpt-4.1-nano
Hier is een voorbeeld van een GitHub Actions workflow die aangepaste meldingen en alerts integreert voor Slack en e-mail, gebaseerd op jouw wensen en bestaande configuratie:
name: CI
on:
push:
branches:
- main # Pas dit aan indien nodig
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build
run: make build
- name: Notify on failure
if: failure()
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
with:
args: |
build-fout in job: ${{ github.job }}
status: failure
commit: ${{ github.sha }}
# Je kunt de berichtinhoud aanpassen voor Slack
- name: Send email on failure
if: failure()
uses: dawidd6/action-send-mail@v3
with:
server_address: smtp.example.com
server_port: 587
username: ${{ secrets.SMTP_USERNAME }}
password: ${{ secrets.SMTP_PASSWORD }}
subject: "Build-fout in job: ${{ github.job }}"
to: jouw-email@voorbeeld.com
from: github-actions@jouw-domein.com
body: |
Er is een build-fout opgetreden in de job: ${{ github.job }}.
Commit: ${{ github.sha }}
Bekijk de details op GitHub: ${{ github.run_url }}
# Trigger bij succesvolle deployment (je moet dit aanpassen afhankelijk van je deployment-setup)
deploy:
needs: build
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
runs-on: ubuntu-latest
steps:
- name: Deployment stap (voorbeeld)
run: echo "Deploying..."
- name: Notify on successful deployment
if: success()
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
with:
args: |
Deployment geslaagd voor job: ${{ github.job }}
status: success
commit: ${{ github.sha }}
- name: Send email on successful deployment
if: success()
uses: dawidd6/action-send-mail@v3
with:
server_address: smtp.example.com
server_port: 587
username: ${{ secrets.SMTP_USERNAME }}
password: ${{ secrets.SMTP_PASSWORD }}
subject: "Succesvolle deployment in job: ${{ github.job }}"
to: jouw-email@voorbeeld.com
from: github-actions@jouw-domein.com
body: |
De deployment is succesvol uitgevoerd in de job: ${{ github.job }}.
Commit: ${{ github.sha }}
Bekijk de details op GitHub: ${{ github.run_url }}
**Belangrijke punten:**
- Voeg je Slack webhook-URL toe als geheim `SLACK_WEBHOOK` in je repository.
- Voeg je SMTP-servergegevens toe als geheimen `SMTP_USERNAME` en `SMTP_PASSWORD`.
- Pas de trigger-branches en deployment-criteria aan naar jouw situatie.
- Je kunt de berichtinhoud verder aanpassen naar jouw wensen.
Wil je dat ik dit verder verfijn of uitbreid?
provider: deepseek
model: deepseek-chat
Hier is een aangepaste GitHub Actions workflow met Slack- en e-mailmeldingen:
```yaml
name: CI met meldingen
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build
run: make build
- name: Build succes melding
if: success()
uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
channel: '#jouw-slack-kanaal'
webhook_url: ${{ secrets.SLACK_WEBHOOK }}
fields: repo,message,commit,author,action,eventName,ref,workflow,job,took
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}
deployment:
runs-on: ubuntu-latest
needs: build
if: success()
steps:
- name: Deployment uitvoeren
run: echo "Deployment logica hier"
- name: Deployment succes e-mail
if: success()
uses: dawidd6/action-send-mail@v3
with:
server_address: smtp.gmail.com
server_port: 465
username: ${{ secrets.MAIL_USERNAME }}
password: ${{ secrets.MAIL_PASSWORD }}
subject: "Deployment succesvol - ${{ github.repository }}"
to: ${{ secrets.NOTIFICATION_EMAIL }}
from: GitHub Actions
body: |
Deployment succesvol voltooid!
Repository: ${{ github.repository }}
Job: ${{ github.job }}
Status: ${{ job.status }}
Commit: ${{ github.sha }}
Workflow: ${{ github.workflow }}
error-notification:
runs-on: ubuntu-latest
needs: [build, deployment]
if: failure()
steps:
- name: Foutmelding naar Slack
uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
channel: '#alerts'
webhook_url: ${{ secrets.SLACK_WEBHOOK }}
fields: repo,message,commit,author,action,eventName,ref,workflow,job,took
- name: Foutmelding e-mail
uses: dawidd6/action-send-mail@v3
with:
server_address: smtp.gmail.com
server_port: 465
username: ${{ secrets.MAIL_USERNAME }}
password: ${{ secrets.MAIL_PASSWORD }}
subject: "Build/Deployment fout - ${{ github.repository }}"
to: ${{ secrets.NOTIFICATION_EMAIL }}
from: GitHub Actions
body: |
Er is een fout opgetreden!
Repository: ${{ github.repository }}
Job: ${{ github.job }}
Status: ${{ job.status }}
Commit: ${{ github.sha }}
Workflow: ${{ github.workflow }}
```
**Benodigde secrets in GitHub repository:**
- `SLACK_WEBHOOK` - Slack webhook URL
- `MAIL_USERNAME` - E-mail gebruikersnaam
- `MAIL_PASSWORD` - E-mail app-wachtwoord
- `NOTIFICATION_EMAIL` - Ontvanger e-mailadres
**Opmerkingen:**
1. Vervang `#jouw-slack-kanaal` met je daadwerkelijke Slack-kanaal
2. Pas de SMTP-instellingen aan voor je e-mailprovider
3. Voeg je deployment logica toe in de deployment job
4. De workflow bevat nu drie jobs: build, deployment en error-notification
5. Meldingen bevatten jobnaam, status en commit-hash zoals gevraagd
Je moet de Slack webhook eerst instellen in je Slack workspace en de secrets toevoegen in je GitHub repository settings.