diff --git a/.github/workflows/cloudflare-pages.yml b/.github/workflows/cloudflare-pages.yml new file mode 100644 index 0000000..80549a1 --- /dev/null +++ b/.github/workflows/cloudflare-pages.yml @@ -0,0 +1,68 @@ +name: Deploy to Cloudflare Pages + +on: + push: + branches: + - main + workflow_dispatch: + +jobs: + deploy: + runs-on: ubuntu-latest + permissions: + contents: read + deployments: write + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '21' + cache: 'npm' + cache-dependency-path: '**/package-lock.json' + + - name: Install dependencies + run: | + cd oauth + npm ci + + - name: Build OAuth app + run: | + cd oauth + npm run build + + - name: Copy OAuth build to static + run: | + mkdir -p my-blog/static/assets + cp -r oauth/dist/assets/* my-blog/static/assets/ + cp oauth/dist/index.html my-blog/static/oauth/index.html || true + + - name: Setup Rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + + - name: Build ailog + run: cargo build --release + + - name: Build site with ailog + run: | + cd my-blog + ../target/release/ailog build + + - name: List public directory + run: | + ls -la my-blog/public/ + + - name: Deploy to Cloudflare Pages + uses: cloudflare/pages-action@v1 + with: + apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} + accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + projectName: ${{ secrets.CLOUDFLARE_PROJECT_NAME }} + directory: my-blog/public + gitHubToken: ${{ secrets.GITHUB_TOKEN }} + wranglerVersion: '3' diff --git a/.gitignore b/.gitignore index fff80cd..1aaeb58 100644 --- a/.gitignore +++ b/.gitignore @@ -5,7 +5,7 @@ *.swo *~ .DS_Store -cloudflare* +cloudflare-config.yml my-blog/public/ dist package-lock.json diff --git a/cloudflared-config.yml b/cloudflared-config.yml new file mode 100644 index 0000000..44d8805 --- /dev/null +++ b/cloudflared-config.yml @@ -0,0 +1,18 @@ +tunnel: ec5a422d-7678-4e73-bf38-6105ffd4766a +credentials-file: /Users/syui/.cloudflared/ec5a422d-7678-4e73-bf38-6105ffd4766a.json + +ingress: + - hostname: log.syui.ai + service: http://localhost:4173 + originRequest: + noHappyEyeballs: true + + - hostname: ollama.syui.ai + service: http://localhost:11434 + originRequest: + noHappyEyeballs: true + httpHostHeader: "localhost:11434" + # Cloudflare Accessを無効化する場合は以下をコメントアウト + # accessPolicy: bypass + + - service: http_status:404 diff --git a/oauth/cloudflared-config.yml b/oauth/cloudflared-config.yml new file mode 100644 index 0000000..b0fb4ae --- /dev/null +++ b/oauth/cloudflared-config.yml @@ -0,0 +1,18 @@ +tunnel: a6813327-f880-485d-a9d1-376e6e3df8ad +credentials-file: /Users/syui/.cloudflared/a6813327-f880-485d-a9d1-376e6e3df8ad.json + +ingress: + ## API backend - 別ドメインで公開 + #- hostname: xxxapi.syui.ai + # service: http://localhost:8000 + # originRequest: + # noHappyEyeballs: true + + # Web frontend + - hostname: xxxcard.syui.ai + service: http://localhost:4173 + originRequest: + noHappyEyeballs: true + + # Catch-all rule + - service: http_status:404