-
Notifications
You must be signed in to change notification settings - Fork 0
100 lines (89 loc) · 3.51 KB
/
Copy pathdeploy.yml
File metadata and controls
100 lines (89 loc) · 3.51 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
name: Deploy to GitHub Pages
on:
push:
branches: [main]
workflow_dispatch:
# Lite 页面上的下载按钮指向构建时查到的那一版安装包。Lite 发了新版之后,
# 不重新构建的话按钮会一直指着旧版本 —— 旧版照样能装、装上会自己更新,
# 但没理由让它停在那里。定时重建一次,最多晚三个小时跟上。
schedule:
- cron: "41 */3 * * *"
# Each job gets only what it needs (below). The build runs third-party code from
# npm with GITHUB_TOKEN in its environment, so it may only read; the Pages
# permissions belong to the deploy job alone.
permissions: {}
concurrency:
group: pages
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@v4
with:
# The sitemap's <lastmod> and the dates on doc pages come from git
# history; a shallow clone would leave them out.
fetch-depth: 0
# The pnpm version comes from package.json's packageManager, the same one
# a local `pnpm` switches to
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 22
cache: pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build site
run: pnpm build
env:
# The build reads versions and releases from the GitHub API; with a
# token the anonymous rate limit does not apply.
GITHUB_TOKEN: ${{ github.token }}
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./dist
deploy:
needs: build
runs-on: ubuntu-latest
permissions:
pages: write # to deploy to GitHub Pages
id-token: write # to verify that the deployment comes from this workflow
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
# Tells the search engines that take IndexNow (Bing, which ChatGPT search
# and Copilot also use, Yandex and others) every address in the sitemap,
# so new and changed pages are crawled soon after a deploy. The key file
# in public/ shows the site is ours. Only for a push or a manual run:
# the scheduled rebuild every three hours would resubmit unchanged pages.
# A failed notification does not fail the deploy.
- name: Notify IndexNow
if: github.event_name != 'schedule'
continue-on-error: true
env:
INDEXNOW_KEY: f7c3fcca3acfc15fb46eca5e1fbde518
run: |
set -euo pipefail
curl -fsSL https://thinkwat.ch/sitemap-0.xml \
| grep -o '<loc>[^<]*</loc>' | sed -e 's/<loc>//' -e 's|</loc>||' > urls.txt
echo "$(wc -l < urls.txt) addresses"
python3 - <<'PY'
import json, os
urls = [u.strip() for u in open("urls.txt") if u.strip()]
key = os.environ["INDEXNOW_KEY"]
json.dump({"host": "thinkwat.ch", "key": key,
"keyLocation": f"https://thinkwat.ch/{key}.txt", "urlList": urls},
open("indexnow.json", "w"))
PY
curl -fsS -o /dev/null -w "IndexNow answered %{http_code}\n" -X POST https://api.indexnow.org/indexnow \
-H "Content-Type: application/json; charset=utf-8" --data @indexnow.json