-
-
Notifications
You must be signed in to change notification settings - Fork 57
62 lines (50 loc) · 1.49 KB
/
Copy pathindex.yml
File metadata and controls
62 lines (50 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
name: Notify IndexNow on Docs Update
on:
push:
branches:
- main
paths:
- 'docs/**'
jobs:
notify-indexnow:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Notify IndexNow
env:
INDEXNOW_KEY: ${{ secrets.INDEX_NOW }}
run: |
echo "Notifying IndexNow about updated docs..."
# Host
HOST="vishalveerareddy123.github.io"
# Secret key pulled from GitHub
KEY="$INDEXNOW_KEY"
# Public key location URL
KEY_LOCATION="https://$HOST/Lynkr/${KEY}.txt"
# Prepare JSON payload
URLS_JSON=$(cat <<EOF
{
"host": "$HOST",
"key": "$KEY",
"keyLocation": "$KEY_LOCATION",
"urlList": [
"https://$HOST/Lynkr/",
"https://$HOST/Lynkr/sitemap.xml"
]
}
EOF
)
echo "Payload:"
echo "$URLS_JSON"
HTTP_CODE=$(curl -s -o /tmp/indexnow_response.txt -w "%{http_code}" \
-X POST "https://www.bing.com/indexnow" \
-H "Content-Type: application/json; charset=utf-8" \
-d "$URLS_JSON")
echo "IndexNow response HTTP code: $HTTP_CODE"
echo "IndexNow response body:"
cat /tmp/indexnow_response.txt
if [ "$HTTP_CODE" -ge 400 ]; then
echo "IndexNow request failed"
exit 1
fi