This repository contains a GitHub Action (post2discord.yml
) and a PowerShell script (`post2discord.ps1) that sends notifications to a Discord channel when a new project version is released. It supports PowerShell modules (.psd1) and C# projects (.csproj).
- Dynamically determine the version of the project.
- Construct a notification message with links to the project on GitHub and either NuGet or PowerShell Gallery.
- Send the notification message to a specified Discord channel via webhook.
The post2discord.yml
is a reusable GitHub Actions workflow that allows you to trigger it via workflow_call
from other workflows in your repository.
source
: The path to the project file (either.psd1
or.csproj
).projectName
: The name of the project, used in the notification message and to construct the URL to PowerShell Gallery or NuGet.
discordWebhook
: The webhook URL for the Discord channel where notifications will be sent.
The post2discord.ps1
PowerShell script sends a formatted message to Discord. It determines the project's version and constructs a message based on the project type.
Source
: Path to the project file.ProjectName
: Name of the project.DiscordWebhook
: Discord webhook URL.
jobs:
call_notify_discord:
uses: ./.github/workflows/post2discord.yml@main
with:
source: 'path/to/projectfile.psd1'
projectName: 'MyProject'
secrets:
discordWebhook: ${{ secrets.DISCORD_WEBHOOK }}
- Store your Discord webhook URL in your repository's secrets as
DISCORD_WEBHOOK
. - Call the
post2discord.yml
workflow from your main workflow file, providing the necessary inputs and secrets.
The script includes basic error handling and will output a simplified error message if it encounters an issue.
Contributions to this project are welcome. Please ensure that you test any changes thoroughly before submitting a pull request.