Skip to content

Commit

Permalink
Add shared notify_discord action
Browse files Browse the repository at this point in the history
  • Loading branch information
Minecraftschurli committed Oct 26, 2023
1 parent 364b95d commit ace699d
Show file tree
Hide file tree
Showing 2 changed files with 122 additions and 0 deletions.
88 changes: 88 additions & 0 deletions .github/workflows/notify_discord.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: "Notify Discord"

on:
workflow_call:
inputs:
project_name:
description: The name of the project used in the message
type: string
required: true
version:
description: The version of the project that was released
type: string
required: true
summary:
description: The summary of the published update
type: string
required: true
curseforge_url:
description: The url to the published version on curseforge
type: string
required: true
modrinth_url:
description: The url to the published version on modrinth
type: string
required: true
github_url:
description: The url to the published version on github
type: string
required: true
logo_url:
description: The url of the logo of the project used for the webhook avatar and the embed thumbnail
type: string
required: true
update_ping:
description: The role or user id to ping with the message
type: string
required: true
embed_color:
description: The color used in the embed
type: string
default: "#00ff00"
secrets:
DISCORD_WEBHOOK:
description: The webhook url for the discord webhook
required: true

jobs:
send-notification:
runs-on: ubuntu-latest
steps:
- name: Get Timestamp
id: timestamp
uses: nanzm/get-time-action@v2.0
with:
format: "YYYY-MM-DDTHH:mm:ssZ"
- name: Send Notification
uses: Minecraftschurli/notify-discord-action@main
with:
webhook_url: ${{ secrets.DISCORD_WEBHOOK }}
username: "${{ inputs.project_name }}"
avatar_url: "${{ inputs.logo_url }}"
message: "<@${{ inputs.update_ping }}> Update version ${{ inputs.version }} for ${{ inputs.project_name }} was released!"
embeds: '[
{
"title": "Update Released",
"timestamp": "${{ steps.timestamp.outputs.time }}",
"color": "${{ inputs.embed_color }}",
"footer": {
"text": "${{ inputs.project_name }}"
},
"thumbnail": {
"url": "${{ inputs.logo_url }}"
},
"author": {
"name": "${{ github.actor }}",
"icon_url": "https://avatars.githubusercontent.com/u/${{ github.actor_id }}"
},
"fields": [
{ "name": "Version", "value": "`${{ inputs.version }}`" },
{ "name": "CurseForge", "value": "[Download](${{ inputs.curseforge_url }})", "inline": true },
{ "name": "Modrinth", "value": "[Download](${{ inputs.modrinth_url }})", "inline": true },
{ "name": "GitHub", "value": "[View](${{ inputs.github_url }})", "inline": true },
{ "name": "Summary", "value": "```${{ inputs.summary }}```" }
]
}
]'
allowed_mentions: |
${{ inputs.update_ping }}
34 changes: 34 additions & 0 deletions .github/workflows/test_discord_notification.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: "Test Discord Notification"

on:
workflow_dispatch:
inputs:
ping:
description: The user or role id to ping
type: string
required: true
version:
description: The version for the notification
type: string
required: false
default: 1.0-test
summary:
description: The summary for the notification
type: string
required: false
default: Test summary

jobs:
notify-discord:
uses: MinecraftschurliMods/.github/.github/workflows/notify_discord.yml@main
with:
project_name: ${{ github.event.repository.title }}
version: ${{ inputs.version }}
summary: ${{ inputs.summary }}
curseforge_url: https://www.curseforge.com/minecraft/mc-mods/ars-magica-legacy
modrinth_url: https://modrinth.com/mod/ars-magica-legacy
github_url: https://github.com/MinecraftschurliMods/ArsMagicaLegacy
logo_url: https://raw.githubusercontent.com/MinecraftschurliMods/ArsMagicaLegacy/version/1.19.x/src/main/resources/logo_small.png
update_ping: ${{ inputs.ping }}
secrets:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_TEST_WEBHOOK }}

0 comments on commit ace699d

Please sign in to comment.