This is a .NET 7.0 application that listens for POST requests from Azure DevOps with information about pushes to a repository. It then formats the data into a Discord-friendly format and sends it to a Discord webhook.
Clone this repository to your local machine.
Set up a service hook in Azure DevOps that sends a POST request to the endpoint /code_pushed
on your server whenever a push event occurs in your desired repository.
Create a new webhook in the desired Discord channel. Copy the webhook URL.
Copy .env.local to new .env file and update the following variables:
Discord_Webhook=your_discord_webhook
BasicAuth__Username=your_username
BasicAuth__Password=your_password
ASPNETCORE_ENVIRONMENT=Production
HOST_API=your_host
Run ngrok and update the webhook url in Azure DevOps to the ngrock url.
ngrok http 7180
Run the application with Docker Compose:
docker-compose up
Run the application with Docker Swarm:
chmod +x deploy.sh
./deploy.sh
The main files in the application are:
Program.cs
: The main entry point for the application.DiscordMessage.cs
: Defines the structure of a message that can be sent to Discord.BasicAuthenticationHandler.cs
: A custom authentication handler for Basic Authentication.appsettings.json
: The application configuration file.AzureMessageToDiscordWebhook.cs
: Defines the mapping between the AzureMessage model and the DiscordMessage model.CodePushed.cs
: Defines the structure of the AzureMessage model.
A Dockerfile
is included for building a Docker image of the application. A docker-compose.yml
file is also included for running the application with Docker Compose.
The application uses the following environment variables:
Discord_Webhook
: The URL of your Discord webhook.BasicAuth__Username
: The username for Basic Authentication.BasicAuth__Password
: The password for Basic Authentication.ASPNETCORE_ENVIRONMENT
: The environment the application is running in. Should beProduction
for a production environment.HOST_API
: The host that Traefik will use to expose your application.
This project is licensed under the terms of the MIT license.