Skip to content

大規模コード改善 - モジュール化・UI刷新・型安全性向上 #3

大規模コード改善 - モジュール化・UI刷新・型安全性向上

大規模コード改善 - モジュール化・UI刷新・型安全性向上 #3

Workflow file for this run

name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "22"
- name: Install dependencies
run: npm install
- name: Type check
run: npx tsc --noEmit
- name: Run tests
run: npx vitest run
preview:
if: github.event_name == 'pull_request'
needs: test
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "22"
- name: Install dependencies
run: npm install
- name: Deploy to preview
id: deploy
run: |
OUTPUT=$(npx wrangler deploy --env preview --minify 2>&1)
echo "$OUTPUT"
PREVIEW_URL=$(echo "$OUTPUT" | grep -oP 'https://[^\s]+\.workers\.dev' | head -1)
echo "preview_url=$PREVIEW_URL" >> "$GITHUB_OUTPUT"
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
- name: Comment preview URL on PR
uses: actions/github-script@v7
with:
script: |
const previewUrl = '${{ steps.deploy.outputs.preview_url }}' || 'https://pera1-preview.<your-subdomain>.workers.dev';
const body = `🚀 **Preview deployed!**\n\n${previewUrl}\n\nThis preview will be updated on every push to this PR.`;
// Find existing bot comment
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
const botComment = comments.find(c =>
c.user.type === 'Bot' && c.body.includes('Preview deployed')
);
if (botComment) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: botComment.id,
body,
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body,
});
}