mirror of
https://github.com/SethCohen/github-releases-to-discord
synced 2026-09-14 20:13:23 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e1dc0826fe | ||
|
|
e768ce1023 | ||
|
|
6ac5abea42 | ||
|
|
6aa0dd988c | ||
|
|
1e7bdfd173 | ||
|
|
47869497ed | ||
|
|
9737dc9002 | ||
|
|
26399c645d | ||
|
|
07c2e1c3e6 | ||
|
|
f184bc59c7 | ||
|
|
3449e38629 | ||
|
|
93d02ce871 | ||
|
|
5dc41089e6 | ||
|
|
5fd64bf266 |
@@ -0,0 +1,15 @@
|
||||
name: Update SemVer Tags
|
||||
on:
|
||||
push:
|
||||
branches-ignore:
|
||||
- '**'
|
||||
tags:
|
||||
- 'v*.*.*'
|
||||
|
||||
jobs:
|
||||
update_semver:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Update semver tags
|
||||
uses: haya14busa/action-update-semver@v1
|
||||
@@ -4,3 +4,7 @@ out
|
||||
gen
|
||||
.env
|
||||
tests/sample-test-release.json
|
||||
release.json
|
||||
repository.json
|
||||
user.json
|
||||
tests/sample-test-release-v2.json
|
||||
|
||||
@@ -1,5 +1,52 @@
|
||||
# Changelog
|
||||
|
||||
## [1.17.0](https://github.com/SethCohen/github-releases-to-discord/compare/v1.16.2...v1.17.0) (2025-06-17)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **workflow:** add GitHub Actions workflow to automatically update SemVer tags on tag push events ([e768ce1](https://github.com/SethCohen/github-releases-to-discord/commit/e768ce10237a6100cccd7e80b2e994e9a2609150))
|
||||
|
||||
## [1.16.2](https://github.com/SethCohen/github-releases-to-discord/compare/v1.16.1...v1.16.2) (2024-10-18)
|
||||
|
||||
|
||||
### Documentation
|
||||
|
||||
* update README output example ([6aa0dd9](https://github.com/SethCohen/github-releases-to-discord/commit/6aa0dd988c547f3b3a73463bc6e69d944621c613))
|
||||
|
||||
## [1.16.1](https://github.com/SethCohen/github-releases-to-discord/compare/v1.16.0...v1.16.1) (2024-10-18)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* correct conversion of standalone PR, issue, and changelog URLs to markdown format ([4786949](https://github.com/SethCohen/github-releases-to-discord/commit/47869497ed80cf0d6188692d82d71dff7a55dffe)), closes [#38](https://github.com/SethCohen/github-releases-to-discord/issues/38)
|
||||
|
||||
|
||||
### Documentation
|
||||
|
||||
* update README with details on markdown link conversion and other features ([9737dc9](https://github.com/SethCohen/github-releases-to-discord/commit/9737dc900274be227db48f8e23c715aa00b4af59))
|
||||
|
||||
## [1.16.0](https://github.com/SethCohen/github-releases-to-discord/compare/v1.15.3...v1.16.0) (2024-10-18)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* add function to convert PR, issue, and changelog links to markdown format ([07c2e1c](https://github.com/SethCohen/github-releases-to-discord/commit/07c2e1c3e60591d601b5d4b5bd4fc90e599867f8)), closes [#32](https://github.com/SethCohen/github-releases-to-discord/issues/32)
|
||||
|
||||
## [1.15.3](https://github.com/SethCohen/github-releases-to-discord/compare/v1.15.2...v1.15.3) (2024-10-18)
|
||||
|
||||
|
||||
### Documentation
|
||||
|
||||
* add contribution guidelines to README.md ([5fd64bf](https://github.com/SethCohen/github-releases-to-discord/commit/5fd64bf266cea87ab4952ef9a4c6aaf099f266bc))
|
||||
* update version reference in README.md ([93d02ce](https://github.com/SethCohen/github-releases-to-discord/commit/93d02ce8714c5f3e201f5b379422e978b837774b))
|
||||
|
||||
|
||||
### Miscellaneous
|
||||
|
||||
* update .gitignore ([3449e38](https://github.com/SethCohen/github-releases-to-discord/commit/3449e38629b0c40dde5af524e2fef220dab24ead))
|
||||
* update package-lock.json ([5dc4108](https://github.com/SethCohen/github-releases-to-discord/commit/5dc41089e63d18b5b191533c34cdddeab34a07e8))
|
||||
|
||||
## [1.15.2](https://github.com/SethCohen/github-releases-to-discord/compare/v1.15.1...v1.15.2) (2024-10-18)
|
||||
|
||||
|
||||
|
||||
@@ -4,20 +4,30 @@ A GitHub Action that sends a stylized Discord webhook containing the description
|
||||
|
||||
## Features
|
||||
|
||||
- Formats release descriptions by:
|
||||
- Removing carriage returns and HTML comments.
|
||||
- Styling headers for better readability in Discord (optional).
|
||||
- Cleaning up redundant whitespace and newlines.
|
||||
- Converting common GitHub links (e.g., PRs, Issues) into clickable URLs.
|
||||
- Limits description length to avoid exceeding Discord's character limits.
|
||||
- Provides customization for the Discord message, including:
|
||||
- Webhook URL, message color, footer text/icon, and timestamp.
|
||||
- Username and avatar for the webhook.
|
||||
- Optional message content outside the embed.
|
||||
- **Text Cleanup:**
|
||||
- **Carriage Return Removal:** Automatically removes carriage return characters for clean formatting.
|
||||
- **HTML Comment Stripping:** Eliminates HTML comments to remove unnecessary information.
|
||||
- **Whitespace Optimization:** Reduces redundant newlines and excess spaces while preserving proper paragraph spacing.
|
||||
- **Mention Conversion:** Converts GitHub mentions (e.g., `@username`) into clickable GitHub profile links for easy navigation.
|
||||
- **Markdown Link Conversion:**
|
||||
- **PR Links:** Converts pull request URLs into Markdown links (e.g., `[PR #1](https://github.com/OWNER/REPO/pull/1)`).
|
||||
- **Issue Links:** Converts issue URLs into Markdown links (e.g., `[Issue #1](https://github.com/OWNER/REPO/issues/1)`).
|
||||
- **Changelog Links:** Converts changelog comparison URLs into concise Markdown links (e.g., `[v1.0.0...v1.1.0](https://github.com/OWNER/REPO/compare/v1.0.0...v1.1.0)`).
|
||||
- **Heading Reduction (Optional):** If enabled, it reduces heading sizes for a cleaner, more compact display:
|
||||
- H3 headings are converted to bold and underlined.
|
||||
- H2 headings are converted to bold.
|
||||
- **Description Length Management:** Ensures the release description fits within Discord's embed message limits (default 4096 characters), trimming excess text by cutting at newlines when possible or adding a continuation link.
|
||||
- **Custom Embed Appearance:**
|
||||
- Set a custom color for the Discord embed message.
|
||||
- Optionally include a custom footer with a title, icon, and a timestamp to make the notification more informative.
|
||||
- **Error Handling:** Provides clear error messages for any invalid or missing inputs, ensuring that the webhook action does not fail silently.
|
||||
- **Webhook Delivery:** Sends the formatted message to the specified Discord channel via webhook, ensuring your release notifications are promptly delivered with the correct details.
|
||||
|
||||
---
|
||||
|
||||
## Output
|
||||

|
||||
|
||||

|
||||
|
||||
## Configuration
|
||||
|
||||
@@ -37,6 +47,7 @@ A GitHub Action that sends a stylized Discord webhook containing the description
|
||||
## Example Usage
|
||||
|
||||
`.github/workflows/github-releases-to-discord.yml`
|
||||
|
||||
```yaml
|
||||
on:
|
||||
release:
|
||||
@@ -49,7 +60,7 @@ jobs:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
- name: Github Releases To Discord
|
||||
uses: SethCohen/github-releases-to-discord@v1.15.1
|
||||
uses: SethCohen/github-releases-to-discord@v1
|
||||
with:
|
||||
webhook_url: ${{ secrets.WEBHOOK_URL }}
|
||||
color: "2105893"
|
||||
@@ -64,14 +75,64 @@ jobs:
|
||||
```
|
||||
|
||||
## Setup Instructions
|
||||
|
||||
1. Open your **Server Settings** and head into the **Integrations** tab:
|
||||
2. Click the "**Create Webhook**" button to create a new webhook!
|
||||

|
||||

|
||||

|
||||

|
||||
3. Copy the webhook url
|
||||
4. Create a new GitHub repository secret called WEBHOOK_URL and paste the webhook url into it.
|
||||

|
||||

|
||||
5. Save the secret.
|
||||
6. Add the secret to your action configuration.
|
||||
|
||||
And you're done! Whenever you create a new release, the workflow should run and, if properly setup, post to your specified Discord channel.
|
||||
|
||||
## Contributing
|
||||
|
||||
If you have suggestions for how GitHub Releases To Discord Action could be improved, or want to report a bug, open an issue! We'd love all and any contributions.
|
||||
|
||||
1. Fork the repository.
|
||||
2. Install node and run `npm install`.
|
||||
3. Install [Github Action tester `act`](https://github.com/nektos/act)
|
||||
4. Create a sample test Release file to simulate a webhook payload object such as `tests/sample-test-release.json` with the following structure:
|
||||
|
||||
```json
|
||||
{
|
||||
"action": "published",
|
||||
"release": {
|
||||
...
|
||||
},
|
||||
"repository": {
|
||||
...
|
||||
},
|
||||
"sender": {
|
||||
...
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
This file will be used to test the action locally and simulate a real release event webhook payload. Refer to the [GitHub Webhook documentation](https://docs.github.com/en/webhooks/webhook-events-and-payloads?actionType=published#release) and the [Github API Documentation](https://docs.github.com/en/rest/releases/releases?apiVersion=2022-11-28#get-a-release) for more information on the webhook payload structure.
|
||||
|
||||
6. Fill the test json file with the necessary fields to simulate a release event.
|
||||
5. Create a test file called `.env` in the main root of the project with the following environmental variables:
|
||||
|
||||
```bash
|
||||
INPUT_WEBHOOK_URL=
|
||||
INPUT_COLOR=
|
||||
INPUT_USERNAME=
|
||||
INPUT_AVATAR_URL=
|
||||
INPUT_CONTENT=
|
||||
INPUT_FOOTER_TITLE=
|
||||
INPUT_FOOTER_ICON_URL=
|
||||
INPUT_FOOTER_TIMESTAMP=
|
||||
INPUT_MAX_DESCRIPTION=
|
||||
INPUT_REDUCE_HEADINGS=
|
||||
```
|
||||
|
||||
8. Fill the `.env` file with your chosen environmental variables values.
|
||||
9. Create a Discord webhook in your server, making sure to add the webhook url to the `.env` file under `INPUT_WEBHOOK_URL=`.
|
||||
10. Run the action locally with `act release -e <your.json>` (e.g., `act release -e tests/sample-test-release.json`) and check the output in your Discord server.
|
||||
11. Confirm that the action works as expected.
|
||||
12. Make your changes and commit them: `git commit -m '<commit_message>'`. Please follow [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/).
|
||||
13. Create the pull request.
|
||||
|
||||
@@ -47,6 +47,32 @@ const reduceHeadings = (text) => text
|
||||
.replace(/^###\s+(.+)$/gm, '**__$1__**') // Convert H3 to bold + underline
|
||||
.replace(/^##\s+(.+)$/gm, '**$1**'); // Convert H2 to bold
|
||||
|
||||
/**
|
||||
* Converts PR, issue, and changelog links to markdown format, ignoring existing markdown links.
|
||||
* - PR links: `https://github.com/OWNER/REPO/pull/1` -> `[PR #1](https://github.com/OWNER/REPO/pull/1)`
|
||||
* - Issue links: `https://github.com/OWNER/REPO/issues/1` -> `[Issue #30](https://github.com/OWNER/REPO/issues/1)`
|
||||
* - Changelog links: `https://github.com/OWNER/REPO/compare/v1.0.0...v1.1.0` -> `[v1.0.0...v1.1.0](https://github.com/OWNER/REPO/compare/v1.0.0...v1.1.0)`
|
||||
* @param {string} text The input text.
|
||||
* @returns {string} The text with links converted to markdown format.
|
||||
*/
|
||||
const convertLinksToMarkdown = (text) => {
|
||||
// Extract existing markdown links and replace them with placeholders
|
||||
const markdownLinks = [];
|
||||
const textWithoutMarkdownLinks = text.replace(/\[.*?\]\(.*?\)/g, (link) => {
|
||||
markdownLinks.push(link);
|
||||
return `__MARKDOWN_LINK_PLACEHOLDER_${markdownLinks.length - 1}__`;
|
||||
});
|
||||
|
||||
// Convert standalone PR, issue, and changelog URLs to markdown format
|
||||
let processedText = textWithoutMarkdownLinks
|
||||
.replace(/https:\/\/github\.com\/([\w-]+)\/([\w-]+)\/pull\/(\d+)/g, (match, owner, repo, prNumber) => `[PR #${prNumber}](${match})`)
|
||||
.replace(/https:\/\/github\.com\/([\w-]+)\/([\w-]+)\/issues\/(\d+)/g, (match, owner, repo, issueNumber) => `[Issue #${issueNumber}](${match})`)
|
||||
.replace(/https:\/\/github\.com\/([\w-]+)\/([\w-]+)\/compare\/([v\w.-]+)\.\.\.([v\w.-]+)/g, (match, owner, repo, fromVersion, toVersion) => `[${fromVersion}...${toVersion}](${match})`);
|
||||
|
||||
// Reinsert the original markdown links
|
||||
return processedText.replace(/__MARKDOWN_LINK_PLACEHOLDER_(\d+)__/g, (match, index) => markdownLinks[parseInt(index, 10)]);
|
||||
};
|
||||
|
||||
/**
|
||||
* Stylizes a markdown body into an appropriate embed message style.
|
||||
* @param {string} description The description to format.
|
||||
@@ -57,6 +83,7 @@ const formatDescription = (description) => {
|
||||
edit = removeHTMLComments(edit);
|
||||
edit = reduceNewlines(edit);
|
||||
edit = convertMentionsToLinks(edit);
|
||||
edit = convertLinksToMarkdown(edit);
|
||||
edit = edit.trim();
|
||||
|
||||
if (core.getBooleanInput('reduce_headings')) {
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "github-releases-to-discord",
|
||||
"version": "1.13.0",
|
||||
"version": "1.15.1",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
|
||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "github-releases-to-discord",
|
||||
"version": "1.15.2",
|
||||
"version": "1.17.0",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "github-releases-to-discord",
|
||||
"version": "1.15.2",
|
||||
"version": "1.17.0",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.10.1",
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "github-releases-to-discord",
|
||||
"version": "1.15.2",
|
||||
"version": "1.17.0",
|
||||
"description": "A GitHub Action that automatically sends a stylized Discord webhook of a GitHub Release description to a specified Discord channel.",
|
||||
"type": "module",
|
||||
"main": "index.js",
|
||||
|
||||
Reference in New Issue
Block a user