Skip to content

Commit afb311d

Browse files
committed
test: add minimal discord workflow
1 parent dedafc4 commit afb311d

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

.github/workflows/discord-test.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: discord-test
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
post:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Post test message to Discord
11+
env:
12+
DISCORD_TOKEN: ${{ secrets.DISCORD_TOKEN }}
13+
DISCORD_CHANNEL_ID: "1473184731037433929"
14+
run: |
15+
python - <<'PY'
16+
import json
17+
import os
18+
import urllib.request
19+
20+
body = {
21+
"content": "**shuvcode Discord test**\n\n- workflow_dispatch smoke test\n- target channel: 1473184731037433929\n- if you can read this, the posting flow still works"
22+
}
23+
24+
req = urllib.request.Request(
25+
f"https://discord.com/api/v10/channels/{os.environ['DISCORD_CHANNEL_ID']}/messages",
26+
data=json.dumps(body).encode(),
27+
headers={
28+
"Authorization": os.environ["DISCORD_TOKEN"],
29+
"Content-Type": "application/json",
30+
},
31+
method="POST",
32+
)
33+
34+
with urllib.request.urlopen(req) as res:
35+
print(res.status)
36+
print(res.read().decode())
37+
PY

0 commit comments

Comments
 (0)