🦾 REFERENCE

Deploy Hooks 使用教程

date
May 14, 2023
slug
hook
author
status
Public
tags
👨🏻‍💻 Program
🗺️ Guide
summary
Vercel 自动重新部署
type
Post
thumbnail
moodyanna_A_fishhook_in_an_underwater_world_with_numerous_octop_2671c023-c6a4-4401-bf0e-4eefc2b82a21.png
category
🦾 REFERENCE
updatedAt
Jul 17, 2023 04:32 AM
因为 Notion 的外链图片有 48 小时失效这个限制,所以构建站点 48 小时之后,来自 Notion 的图片就会加载不成功。这时候重新触发一次构建即可刷新图片链接。
下面以在 Vercel 部署为例,在 Vercel 管理后台,对应项目内的 Settings > Git 设置页面中,创建一个 Deploy Hook:
notion image
在代码仓库里新建一个目录结构 .github/workflows 并在里面新建一个文件叫 cron.yaml, 最终结构如下图:
notion image
文件的代码如下:
name: auto-update-cron
on:
  schedule:
    - cron: '0 0 * * *'
jobs:
  build:
    name: Trigger Site Rebuild
    runs-on: ubuntu-latest
    steps:
      - name: Call Vercel Hook
        run: curl -X POST "https://api.vercel.com/v1/integrations/deploy/prj_xxxxxxxxx/ooooooooo?buildCache=false"
配置里的 URL 改成你新建的 Deploy Hook 地址。设置好后 GitHub 会每天 0 点通知 Vercel 重新构建站点。