Skip to content

v4.0.48.1

v4.0.48.1 #27

Workflow file for this run

name: Notify Discord on Release
permissions:
contents: read
on:
workflow_dispatch:
release:
types:
- published
- edited
jobs:
notify-discord:
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v6
env:
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
// Function to format links and remove comments
const formatContent = (text) =>
text
.replace(/(https?:\/\/[^\s)]+)/g, '<$1>') // Wrap URLs in <>
.replace(/<!--.*?-->/gs, '') // Remove all HTML comments
const releaseBody = formatContent(`${{ github.event.release.body }}`)
const options = {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
username: 'Release Bot',
avatar_url: 'https://getautoclicker.com/docs/4.x/assets/brand/bootstrap-social-logo.png',
content: '@everyone\n${{ github.actor }} published a new release: [${{ github.event.release.tag_name }}](${{ github.event.release.html_url }})'+releaseBody,
}),
};
const response = await fetch(process.env.DISCORD_WEBHOOK_URL, options);
console.log(response.status);