Skip to content

Commit 890cac7

Browse files
authored
Merge pull request #22 from Jsweb-Tech/Docs/Update
Docs & workflow update
2 parents faba5be + 08497a6 commit 890cac7

File tree

3 files changed

+85
-11
lines changed

3 files changed

+85
-11
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Discord PR Notifier
2+
3+
on:
4+
pull_request:
5+
types: [opened, reopened, closed]
6+
7+
jobs:
8+
notify:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Send PR info to Discord
12+
env:
13+
DISCORD_WEBHOOK_URL_4: ${{ secrets.DISCORD_WEBHOOK_URL_4 }}
14+
run: |
15+
ACTION="${{ github.event.action }}"
16+
MERGED="${{ github.event.pull_request.merged }}"
17+
18+
# Ignore closed but not merged PRs
19+
if [ "$ACTION" = "closed" ] && [ "$MERGED" != "true" ]; then
20+
exit 0
21+
fi
22+
23+
if [ "$ACTION" = "opened" ]; then
24+
TITLE="🆕 Pull Request Opened"
25+
COLOR=3447003
26+
elif [ "$ACTION" = "reopened" ]; then
27+
TITLE="🔄 Pull Request Reopened"
28+
COLOR=16776960
29+
else
30+
TITLE="✅ Pull Request Merged"
31+
COLOR=3066993
32+
fi
33+
34+
curl -X POST "$DISCORD_WEBHOOK_URL_4" \
35+
-H "Content-Type: application/json" \
36+
-d @- << EOF
37+
{
38+
"username": "GitHub PR Bot",
39+
"avatar_url": "https://github.com/github.png",
40+
"embeds": [
41+
{
42+
"title": "$TITLE",
43+
"url": "${{ github.event.pull_request.html_url }}",
44+
"description": "**${{ github.event.pull_request.title }}**",
45+
"color": $COLOR,
46+
"author": {
47+
"name": "${{ github.event.pull_request.user.login }}",
48+
"url": "${{ github.event.pull_request.user.html_url }}",
49+
"icon_url": "${{ github.event.pull_request.user.avatar_url }}"
50+
},
51+
"fields": [
52+
{
53+
"name": "Base → Head",
54+
"value": "${{ github.event.pull_request.base.ref }} → ${{ github.event.pull_request.head.ref }}",
55+
"inline": true
56+
},
57+
{
58+
"name": "Repository",
59+
"value": "${{ github.repository }}",
60+
"inline": true
61+
}
62+
],
63+
"footer": {
64+
"text": "JsWeb Framework • Pull Requests"
65+
}
66+
}
67+
]
68+
}
69+
EOF
Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,31 @@
11
name: Discord Release Notifier
22

3-
# This action will only trigger when a new release is "published".
4-
# It won't trigger on drafts or pre-releases.
53
on:
64
release:
75
types: [published]
86

97
jobs:
108
notify:
11-
name: Send Discord Notification
129
runs-on: ubuntu-latest
1310
steps:
1411
- name: Send Release Info to Discord
1512
env:
16-
# We securely access the webhook URL from the GitHub secret we created.
1713
DISCORD_WEBHOOK_URL_1: ${{ secrets.DISCORD_WEBHOOK_URL_1 }}
1814
run: |
19-
# This command uses `curl` to send a POST request with a JSON payload.
20-
# The JSON creates a nice-looking "embed" in Discord.
15+
# Truncate release notes to avoid Discord limit (4000 chars safe)
16+
BODY=$(echo "${{ github.event.release.body }}" | head -c 4000)
17+
2118
curl -X POST "$DISCORD_WEBHOOK_URL_1" \
22-
-H "Content-Type: application/json" \
23-
-d @- << EOF
19+
-H "Content-Type: application/json" \
20+
-d @- << EOF
2421
{
25-
"username": "Github Releases",
22+
"username": "GitHub Releases",
2623
"avatar_url": "https://github.com/github.png",
2724
"embeds": [
2825
{
2926
"title": "🚀 New Release: ${{ github.event.release.name }}",
3027
"url": "${{ github.event.release.html_url }}",
31-
"description": "${{ github.event.release.body }}",
28+
"description": "$BODY\n\n🔗 **Read full changelog on GitHub**",
3229
"color": 5814783,
3330
"author": {
3431
"name": "${{ github.event.release.author.login }}",
@@ -41,4 +38,4 @@ jobs:
4138
}
4239
]
4340
}
44-
EOF
41+
EOF

docs/forms.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,11 @@ In your template, you can then render the form fields individually.
9797
<button type="submit">Log In</button>
9898
</form>
9999
```
100+
101+
## CSRF Protection
102+
103+
JsWeb provides built-in CSRF protection. For traditional forms, you can include a hidden `csrf_token` field in your form, as shown in the example above.
104+
105+
> **Note for the Next Version:**
106+
>
107+
> For SPAs and API-first applications, the next version of JsWeb will also support sending the CSRF token in the `X-CSRF-Token` HTTP header. This is the recommended approach for modern web applications.

0 commit comments

Comments
 (0)