Skip to content

Commit 95bedb2

Browse files
authored
Update index.md
1 parent c3c491e commit 95bedb2

File tree

1 file changed

+9
-3
lines changed
  • content/posts/deploy twikoo on netlify

1 file changed

+9
-3
lines changed

content/posts/deploy twikoo on netlify/index.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ tags:
1313

1414
> 在本篇文章里,我会介绍如何在Netlify上部署Twikoo评论系统,如何接入到静态博客Hugo,以及如何实现Twikoo系统版本自动更新。
1515
16+
*2024年7月30日更新:因为[Github接口策略调整](https://docs.github.com/rest/overview/resources-in-the-rest-api#rate-limiting),原有的匿名通过接口获取版本号方法失效,已更改为带token方式请求接口获取版本号,详见workflow里Get twikoo version步骤配置。*
17+
1618
#### 背景
1719

1820
博客之前通过`Vercel`部署了`Twikoo`评论系统,但是最近发现加载很慢。
@@ -145,10 +147,14 @@ jobs:
145147
146148
# Runs a single command using the runners shell
147149
- name: update version
150+
env:
151+
github_token: ${{ secrets.TOKEN }}
148152
run: |
149-
response=$(curl -s https://api.github.com/repos/twikoojs/twikoo/releases/latest)
153+
response=$(curl -sf -H "Authorization: token $github_token" -H "Accept: application/vnd.github+json" https://api.github.com/repos/twikoojs/twikoo/releases/latest)
150154
version=$(echo $response | jq -r '.tag_name')
151-
sed -i "s/\"twikoo-netlify\": \".*\"/\"twikoo-netlify\": \"$version\"/" package.json
155+
if [ -n "$version" ]; then
156+
sed -i "s/\"twikoo-netlify\": \".*\"/\"twikoo-netlify\": \"$version\"/" package.json
157+
fi
152158
shell: bash
153159
154160
# Runs a set of commands using the runners shell
@@ -227,4 +233,4 @@ params:
227233

228234
需要将`https://raw.githubusercontent.com/Liudon/twikoo-netlify/main/package.json`这个url里的`Liudon/twikoo-netlify`改为你的仓库名。
229235

230-
这下后面`Twikoo`官方更新版本,博客的`Twikoo`也会跟着自动更新。
236+
这下后面`Twikoo`官方更新版本,博客的`Twikoo`也会跟着自动更新。

0 commit comments

Comments
 (0)