From fea9263f06a9c1e1b11914dffc2b36061b7591a6 Mon Sep 17 00:00:00 2001 From: guarin Date: Wed, 15 Nov 2023 09:09:37 +0000 Subject: [PATCH] Add discord release notification --- .../discord_release_notification.yml | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .github/workflows/discord_release_notification.yml diff --git a/.github/workflows/discord_release_notification.yml b/.github/workflows/discord_release_notification.yml new file mode 100644 index 000000000..47367714b --- /dev/null +++ b/.github/workflows/discord_release_notification.yml @@ -0,0 +1,37 @@ +name: Discord Release Notification + +on: + release: + types: [published] + +jobs: + notify-discord: + runs-on: ubuntu-latest + steps: + - name: Send Notification to Discord + env: + DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} + # We truncate the description at the models section (starting with ### Models) + # to keep the message short. + # We have also have to format the release description for it to be valid JSON. + # This is done by piping the description to jq. + run: | + DESCRIPTION=$(echo '${{ github.event.release.body }}' | awk '/### Models/{exit}1' | jq -aRs .) + curl -H "Content-Type: application/json" \ + -X POST \ + -d @- \ + "${DISCORD_WEBHOOK}" << EOF + { + "username": "Lightly", + "avatar_url": "https://avatars.githubusercontent.com/u/50146475", + "content": "Lightly ${{ github.event.release.tag_name }} has been released!", + "embeds": [ + { + "title": "${{ github.event.release.name }}", + "url": "${{ github.event.release.html_url }}", + "color": 5814783, + "description": $DESCRIPTION + } + ] + } + EOF