Skip to content
name: Discord Publish Release Notes 🎮
on:
release:
types: [published]
jobs:
build:
runs-on: ubuntu-latest
env:
DISCORD_CHANNEL: "954504327949582429"
GITHUB_CONTEXT: ${{ toJSON(github) }}
steps:
# To check the github context
- name: Dump Github context
run: echo "$GITHUB_CONTEXT"
# Push next release notes to Discord
- name: Push pre-release note to Discord
if: ${{ github.event.release.prerelease == true }}
run: |
jq -r '.content = "<:s42next:1000046992250126376> <@&1130464635846402139> \n\n" + .content[0:1800]' << EOF | jq -sRr . | curl --request POST \
--url 'https://discord.com/api/v9/channels/${{ env.DISCORD_CHANNEL }}/messages' \
--header 'Authorization: Bot ${{ secrets.DISCORD_BOT_TOKEN }}' \
--header 'Content-Type: application/json' \
--data @-
{
"content": ${{ toJSON(fromJSON(env.GITHUB_CONTEXT).event.release.body) }},
"tts": false,
"flags": 100,
"components": [
{
"type": 1,
"components": [
{
"style": 5,
"label": "Next",
"url": "https://next.s42.app",
"disabled": false,
"emoji": {
"id": "1000046992250126376",
"name": "s42next",
"animated": false
},
"type": 2
},
{
"style": 5,
"label": "Show Full Release",
"url": "https://github.com/42Atomys/stud42/releases/tag/${{ github.event.release.tag_name }}",
"disabled": false,
"type": 2
}
]
}
]
}
EOF
# Push live release notes to Discord
- name: Push release note to Discord
if: ${{ github.event.release.prerelease == false }}
run: |
jq -r '.content = "<:s42:972976005604081744> <@&1130464635846402139> \n\n" + .content[0:1800]' << EOF | jq -sRr . | curl --request POST \
--url 'https://discord.com/api/v9/channels/${{ env.DISCORD_CHANNEL }}/messages' \
--header 'Authorization: Bot ${{ secrets.DISCORD_BOT_TOKEN }}' \
--header 'Content-Type: application/json' \
--data @-
{
"content": ${{ toJSON(fromJSON(env.GITHUB_CONTEXT).event.release.body) }},
"tts": false,
"components": [
{
"type": 1,
"components": [
{
"style": 5,
"label": "Live",
"url": "https://s42.app",
"disabled": false,
"emoji": {
"id": "972976005604081744",
"name": "s42",
"animated": false
},
"type": 2
},
{
"style": 5,
"label": "Show Full Release",
"url": "https://github.com/42Atomys/stud42/releases/tag/${{ github.event.release.tag_name }}",
"disabled": false,
"type": 2
}
]
}
]
}
EOF