この
この
この
- タグクラウド
- 検索モーダルを
開いた ときの 初期表示 - 記事下部に
ある 関連記事
今は
実装方 法
- Vercel の
Deploy Hook を 作成する - Vercel の
Cron Jobs を 使う - デプロイを
実行する API を 作成する
やる
Vercel の Deploy Hook を 作成する
まずは
この
ただし、
デフォルトだと?buildCache=false を
Vercel の Cron Jobs を 設定する
次に、
vercel.json に
{ "crons": [ { "path": "/api/cron/deploy", "schedule": "0 18 * * *" } ]}ここで0 18 * * * と
ちなみに
デプロイを 実行する API を 作成する
あとは/api/cron/deploy に
import { env } from "#/env";
const createResponse = (message: string, status: number) => new Response(message, { status, headers: { "Content-Type": "text/plain", "X-Content-Type-Options": "nosniff", }, });
export const GET = async (request: Request) => { const webhookUrl = env.VERCEL_DEPLOY_HOOK_URL;
if (!webhookUrl) { return createResponse("Deploy hook URL is missing", 500); }
const authHeader = request.headers.get("authorization");
if (authHeader !== `Bearer ${env.CRON_SECRET}`) { return createResponse("Unauthorized", 401); }
try { const response = await fetch(webhookUrl, { method: "POST" });
if (response.ok) { return createResponse("Redeployment triggered", 200); }
console.error( `Failed to trigger redeployment: ${response.status} ${response.statusText}`, );
return createResponse("Failed to trigger redeployment", 500); } catch (error) { console.error("Error communicating with deploy hook", error); return createResponse("Error communicating with deploy hook", 500); }};ここで
それはCRON_SECRET)をAuthorizationBearer トークン のCRON_SECRET と
このCRON_SECRET を
実際に 動くかテスト
実装に
curl -X GET "https://xxx.com/api/cron/deploy" \-H "Authorization: Bearer xxx"さい ごに
何でも


