mirror of
https://github.com/SethCohen/github-releases-to-discord
synced 2026-09-14 20:13:23 +00:00
Merge pull request #18 from iCiaran/rename-context-variables
refactor: rename variables returned from getContext
This commit is contained in:
@@ -25,9 +25,9 @@ async function run () {
|
|||||||
return core.setFailed('webhook_url not set. Please set it.')
|
return core.setFailed('webhook_url not set. Please set it.')
|
||||||
}
|
}
|
||||||
|
|
||||||
const content = await getContext()
|
const {body, html_url, version} = await getContext()
|
||||||
|
|
||||||
const description = content.body
|
const description = body
|
||||||
.replace(/### (.*?)\n/g,function (substring) {
|
.replace(/### (.*?)\n/g,function (substring) {
|
||||||
const newString = substring.slice(4).replace(/(\r\n|\n|\r)/gm, "")
|
const newString = substring.slice(4).replace(/(\r\n|\n|\r)/gm, "")
|
||||||
return `**__${newString}__**`
|
return `**__${newString}__**`
|
||||||
@@ -39,19 +39,19 @@ async function run () {
|
|||||||
.replace(/\n\s*\n/g, '\n')
|
.replace(/\n\s*\n/g, '\n')
|
||||||
|
|
||||||
const embedMsg = {
|
const embedMsg = {
|
||||||
title: `Release ${content.version}`,
|
title: `Release ${version}`,
|
||||||
url: content.html_url,
|
url: html_url,
|
||||||
color: color,
|
color: color,
|
||||||
description: description,
|
description: description,
|
||||||
}
|
}
|
||||||
|
|
||||||
const body = { username: username, avatar_url: avatarUrl, embeds: [embedMsg], }
|
const requestBody = { username: username, avatar_url: avatarUrl, embeds: [embedMsg], }
|
||||||
|
|
||||||
const url = `${webhookUrl}?wait=true`
|
const url = `${webhookUrl}?wait=true`
|
||||||
|
|
||||||
fetch(url, {
|
fetch(url, {
|
||||||
method: 'post',
|
method: 'post',
|
||||||
body: JSON.stringify(body),
|
body: JSON.stringify(requestBody),
|
||||||
headers: { 'Content-Type': 'application/json' }
|
headers: { 'Content-Type': 'application/json' }
|
||||||
})
|
})
|
||||||
.then(res => res.json())
|
.then(res => res.json())
|
||||||
|
|||||||
Reference in New Issue
Block a user