v4.0.47.2 #24
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Notify Discord on Release | |
on: | |
workflow_dispatch: | |
release: | |
types: | |
- published | |
- edited | |
jobs: | |
notify-discord: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/github-script@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); |