Compare commits

..
9 Commits
5 changed files with 52 additions and 10 deletions
+15
View File
@@ -1,5 +1,20 @@
# Changelog # Changelog
## [1.3.0](https://github.com/SethCohen/github-release-to-discord/compare/v1.2.0...v1.3.0) (2022-08-24)
### Features
* changed default action colour ([79005b2](https://github.com/SethCohen/github-release-to-discord/commit/79005b23fefce850957d37ba17ebb796dc81f6a1))
* updated description format ([a1d7a74](https://github.com/SethCohen/github-release-to-discord/commit/a1d7a74af90fcf8c00d341c8c665ca796b18c689))
## [1.2.0](https://github.com/SethCohen/github-release-to-discord/compare/v1.1.0...v1.2.0) (2022-08-24)
### Features
* updated action ([b612527](https://github.com/SethCohen/github-release-to-discord/commit/b6125273330075a9f4de3e58f2fc7f52d85d4691))
## [1.1.0](https://github.com/SethCohen/github-release-to-discord/compare/v1.0.0...v1.1.0) (2022-08-24) ## [1.1.0](https://github.com/SethCohen/github-release-to-discord/compare/v1.0.0...v1.1.0) (2022-08-24)
+12
View File
@@ -4,6 +4,18 @@ inputs:
webhook_url: webhook_url:
description: Discord's webhook url. Use GH repo secrets. description: Discord's webhook url. Use GH repo secrets.
required: true required: true
colour:
description: Decimal colour value for embed.
required: false
default: '202225'
username:
description: String username for webhook.
required: false
default: 'Release Changelog'
avatar_url:
description: String url to webhook avatar picture.
required: false
default: 'https://cdn.discordapp.com/avatars/487431320314576937/bd64361e4ba6313d561d54e78c9e7171.png'
runs: runs:
using: 'node16' using: 'node16'
main: 'index.js' main: 'index.js'
+22 -7
View File
@@ -1,6 +1,5 @@
const core = require('@actions/core'); const core = require('@actions/core');
const github = require('@actions/github'); const github = require('@actions/github');
const fetch = require('node-fetch') const fetch = require('node-fetch')
async function getContext () { async function getContext () {
@@ -18,6 +17,9 @@ async function getContext () {
async function run () { async function run () {
try { try {
const webhookUrl = core.getInput('webhook_url') const webhookUrl = core.getInput('webhook_url')
const colour = core.getInput('colour')
const username = core.getInput('username')
const avatarUrl = core.getInput('avatar_url')
if (!webhookUrl) { if (!webhookUrl) {
return core.setFailed('webhook_url not set. Please set it.') return core.setFailed('webhook_url not set. Please set it.')
@@ -25,14 +27,27 @@ async function run () {
const content = await getContext() const content = await getContext()
const embedMsg = { let description = '';
color: 3447003, for (const line of content.body) {
title: `Release ${content.version}`, if (line.startsWith('## ')) {
description: content.body, description += `**${line.slice(3)}**\n`;
url: content.html_url }
else if (line.startsWith('### ')) {
description += `**__${line.slice(4)}__**\n`;
}
else if (line.startsWith('* ')) {
description += `- ${line.slice(2)}\n`;
}
} }
const body = { embeds: [embedMsg] } const embedMsg = {
title: `Release ${content.version}`,
url: content.html_url,
color: colour,
description: description,
}
const body = { username: username, avatar_url: avatarUrl, embeds: [embedMsg], }
const url = `${webhookUrl}?wait=true` const url = `${webhookUrl}?wait=true`
+2 -2
View File
@@ -1,12 +1,12 @@
{ {
"name": "github-release-to-discord", "name": "github-release-to-discord",
"version": "1.1.0", "version": "1.3.0",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "github-release-to-discord", "name": "github-release-to-discord",
"version": "1.1.0", "version": "1.3.0",
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"@actions/core": "^1.9.1", "@actions/core": "^1.9.1",
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "github-release-to-discord", "name": "github-release-to-discord",
"version": "1.1.0", "version": "1.3.0",
"description": "", "description": "",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {