Skip to content

Commit d015096

Browse files
authored
Update update-mod.yml
1 parent f7fa376 commit d015096

File tree

1 file changed

+36
-3
lines changed

1 file changed

+36
-3
lines changed

.github/workflows/update-mod.yml

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Update Mod
1+
name: Mod Update Jobs
22

33
on:
44
release:
@@ -10,7 +10,7 @@ jobs:
1010

1111
steps:
1212
- name: Checkout repository
13-
uses: actions/checkout@v2
13+
uses: actions/checkout@v3
1414

1515
- name: Set up Rust
1616
uses: actions-rs/toolchain@v1
@@ -33,4 +33,37 @@ jobs:
3333
echo "::set-output name=url::$attachment_url"
3434
3535
- name: Update mods using geode CLI
36-
run: geode index mods update ${{ steps.find-attachment.outputs.url }}
36+
run: geode index mods update ${{ steps.find-attachment.outputs.url }}
37+
38+
- name: Send message to Discord
39+
env:
40+
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
41+
run: |
42+
# Install jq if it's not already available
43+
sudo apt-get install -y jq
44+
45+
# Extract release details
46+
RELEASE_NAME="${{ github.event.release.name }}"
47+
RELEASE_BODY="${{ github.event.release.body }}"
48+
RELEASE_URL="${{ github.event.release.html_url }}"
49+
50+
# Get the URL of the attachment (first mod file)
51+
ATTACHMENT_URL=$(echo "${{ github.event.release.assets }}" | jq -r '.[] | select(.name | contains("mod")) | .browser_download_url' | head -n 1)
52+
53+
# Escape special characters in the release body
54+
ESCAPED_BODY=$(echo "$RELEASE_BODY" | sed 's/"/\\"/g' | sed 's/\n/\\n/g')
55+
56+
# Construct the message payload
57+
MESSAGE=$(jq -n \
58+
--arg name "$RELEASE_NAME" \
59+
--arg body "$ESCAPED_BODY" \
60+
--arg url "$RELEASE_URL" \
61+
--arg attachment "$ATTACHMENT_URL" \
62+
'{
63+
content: "A new update has been released!\n\n**\($name)**\n\n\($body)\n\n[Download Attachment](\($attachment))\n\n[Release URL](\($url))"
64+
}')
65+
66+
# Send the message to Discord
67+
curl -X POST $DISCORD_WEBHOOK_URL \
68+
-H "Content-Type: application/json" \
69+
-d "$MESSAGE"

0 commit comments

Comments
 (0)