Skip to content

chore(deps): update dependency wrangler to v4.73.0 #92

chore(deps): update dependency wrangler to v4.73.0

chore(deps): update dependency wrangler to v4.73.0 #92

name: Preview Deploy
on:
pull_request:
types: [opened, synchronize, reopened]
branches:
- main
paths:
- "src/**"
- "public/**"
- "package.json"
- "pnpm-lock.yaml"
- "next.config.mjs"
- "contentlayer.config.ts"
- "tailwind.config.ts"
- "wrangler.jsonc"
- "tsconfig.json"
- "drizzle/**"
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
WORKER_NAME: blog
WORKERS_SUBDOMAIN: ${{ secrets.WORKERS_SUBDOMAIN }}
jobs:
preview-deploy:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v6
- name: Post deploying comment
uses: actions/github-script@v8
with:
script: |
const prNum = context.issue.number;
const alias = `pr-${prNum}`;
const previewUrl = `https://${alias}-${{ env.WORKER_NAME }}.${{ env.WORKERS_SUBDOMAIN }}.workers.dev`;
const body = `## Preview Deploy\n\n**Status**: :hourglass_flowing_sand: デプロイ中...\n\n予定URL: ${previewUrl}`;
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNum,
});
const botComment = comments.find(c =>
c.user.type === 'Bot' && c.body.includes('Preview Deploy')
);
if (botComment) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: botComment.id,
body: body,
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNum,
body: body,
});
}
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 10
- name: Use Node.js
uses: actions/setup-node@v6
with:
node-version: 24.12.0
cache: "pnpm"
- name: Install dependencies
run: pnpm install
- name: Build content
run: pnpm build:content
- name: Deploy preview
id: deploy
run: |
PR_NUM=${{ github.event.pull_request.number }}
ALIAS="pr-${PR_NUM}"
# OpenNext ビルド
pnpm exec opennextjs-cloudflare build
# プレビューバージョンアップロード
pnpm exec opennextjs-cloudflare upload --preview-alias ${ALIAS}
# プレビューURL生成
PREVIEW_URL="https://${ALIAS}-${{ env.WORKER_NAME }}.${{ env.WORKERS_SUBDOMAIN }}.workers.dev"
echo "preview_url=${PREVIEW_URL}" >> $GITHUB_OUTPUT
- name: Update comment on success
if: success()
uses: actions/github-script@v8
with:
script: |
const prNum = context.issue.number;
const previewUrl = '${{ steps.deploy.outputs.preview_url }}';
const body = `## Preview Deploy\n\n**Status**: :white_check_mark: デプロイ完了\n\n**Preview URL**: ${previewUrl}\n\n---\n*このプレビューはPRがクローズされるまで利用可能です。*`;
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNum,
});
const botComment = comments.find(c =>
c.user.type === 'Bot' && c.body.includes('Preview Deploy')
);
if (botComment) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: botComment.id,
body: body,
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNum,
body: body,
});
}
- name: Update comment on failure
if: failure()
uses: actions/github-script@v8
with:
script: |
const prNum = context.issue.number;
const runUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${{ github.run_id }}`;
const body = `## Preview Deploy\n\n**Status**: :x: デプロイ失敗\n\n詳細は[ワークフローログ](${runUrl})を確認してください。`;
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNum,
});
const botComment = comments.find(c =>
c.user.type === 'Bot' && c.body.includes('Preview Deploy')
);
if (botComment) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: botComment.id,
body: body,
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNum,
body: body,
});
}