Skip to content

Commit 8d2e07b

Browse files
committed
Fix workflow
1 parent 8d65c0e commit 8d2e07b

File tree

1 file changed

+41
-11
lines changed

1 file changed

+41
-11
lines changed

.github/workflows/releases-to-discord.yml

Lines changed: 41 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,51 @@ name: Release to Discord
33
on:
44
release:
55
types: [published]
6+
workflow_dispatch: {}
67

78
jobs:
8-
github-releases-to-discord:
9+
notify-discord:
910
runs-on: ubuntu-latest
1011
steps:
11-
- name: Checkout
12-
uses: actions/checkout@v3
13-
- name: Github Releases To Discord
14-
uses: SethCohen/[email protected]
12+
- name: Determine Release Info
13+
id: release-info
14+
run: |
15+
if [ "${{ github.event.release.tag_name != '' }}" = "true" ]; then
16+
echo "Using release event payload"
17+
echo "RELEASE_NAME=${{ github.event.release.name }}" >> $GITHUB_ENV
18+
echo "RELEASE_URL=${{ github.event.release.html_url }}" >> $GITHUB_ENV
19+
echo "RELEASE_TIMESTAMP=${{ github.event.release.published_at }}" >> $GITHUB_ENV
20+
CLEAN_BODY=$(echo "${{ github.event.release.body }}" | tr -d '\r')
21+
echo "RELEASE_BODY<<EOF" >> $GITHUB_ENV
22+
echo "$CLEAN_BODY" >> $GITHUB_ENV
23+
echo "EOF" >> $GITHUB_ENV
24+
else
25+
echo "Fetching latest release from GitHub API"
26+
response=$(curl -s https://api.github.com/repos/${{ github.repository }}/releases/latest)
27+
name=$(echo "$response" | jq -r '.name')
28+
body=$(echo "$response" | jq -r '.body // "No changelog provided."' | tr -d '\r')
29+
url=$(echo "$response" | jq -r '.html_url')
30+
timestamp=$(echo "$response" | jq -r '.published_at')
31+
32+
echo "RELEASE_NAME=$name" >> $GITHUB_ENV
33+
echo "RELEASE_URL=$url" >> $GITHUB_ENV
34+
echo "RELEASE_TIMESTAMP=$timestamp" >> $GITHUB_ENV
35+
echo "RELEASE_BODY<<EOF" >> $GITHUB_ENV
36+
echo "$body" >> $GITHUB_ENV
37+
echo "EOF" >> $GITHUB_ENV
38+
fi
39+
40+
- name: Send to Discord
41+
uses: tsickert/[email protected]
1542
with:
16-
webhook_url: ${{ secrets.RELEASE_WEBHOOK_URL }}
17-
color: "2105893"
43+
webhook-url: ${{ secrets.RELEASE_WEBHOOK_URL }}
1844
username: "Release"
19-
avatar_url: "https://cdn.discordapp.com/avatars/1184778180515606560/52b7876fc8cefa73f593c7f8b95811f3.webp?size=160"
45+
avatar-url: "https://cdn.discordapp.com/avatars/1184778180515606560/52b7876fc8cefa73f593c7f8b95811f3.webp?size=160"
2046
content: "||@everyone||"
21-
footer_title: "Changelog"
22-
footer_icon_url: "https://cdn.discordapp.com/avatars/1184778180515606560/52b7876fc8cefa73f593c7f8b95811f3.webp?size=160"
23-
footer_timestamp: true
47+
embed-title: "📦 New Release: ${{ env.RELEASE_NAME }}"
48+
embed-url: "${{ env.RELEASE_URL }}"
49+
embed-description: "${{ env.RELEASE_BODY }}"
50+
embed-color: 2105893
51+
embed-footer-text: "Changelog"
52+
embed-footer-icon-url: "https://cdn.discordapp.com/avatars/1184778180515606560/52b7876fc8cefa73f593c7f8b95811f3.webp?size=160"
53+
embed-timestamp: "${{ env.RELEASE_TIMESTAMP }}"

0 commit comments

Comments
 (0)