diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 903754a..6b69fc5 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,10 +1,12 @@ -name: Deploy to Cloudflare Pages +name: Deploy to Cloudflare Workers on: release: types: [published] pull_request: branches: [main] + types: [opened, synchronize, reopened] + workflow_dispatch: jobs: deploy: @@ -12,7 +14,7 @@ jobs: permissions: contents: read deployments: write - pull-requests: write + pull-requests: write steps: - name: Checkout uses: actions/checkout@v4 @@ -28,13 +30,29 @@ jobs: - name: Build run: bun run build - - name: Deploy to Cloudflare Pages + - name: Verify build output + run: | + echo "Build output contents:" + ls -la dist/ || echo "dist folder not found!" + + - name: Deploy to Production + if: github.event_name == 'release' + uses: cloudflare/wrangler-action@v3 + id: deploy-prod + with: + apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} + accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + command: deploy + gitHubToken: ${{ secrets.GITHUB_TOKEN }} + + - name: Upload Preview Version + if: github.event_name == 'pull_request' uses: cloudflare/wrangler-action@v3 - id: cloudflare + id: deploy-preview with: apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} - command: pages deploy dist --project-name=codeink ${{ github.event_name == 'release' && '--branch=main' || '' }} + command: versions upload --tag ${{ github.head_ref }} --assets ./dist gitHubToken: ${{ secrets.GITHUB_TOKEN }} - name: Comment PR @@ -42,21 +60,23 @@ jobs: uses: actions/github-script@v6 with: script: | - const url = '${{ steps.cloudflare.outputs.deployment-url }}'; - const alias = '${{ steps.cloudflare.outputs.pages-deployment-alias-url }}'; - - const body = `### Cloudflare pages deployed! - + const branch = context.payload.pull_request.head.ref; + const previewUrl = `https://${branch}-codeink.jorgeflorentinomarbe.workers.dev`; + + const body = `### 🚀 Cloudflare Workers Preview Deployment + | Name | Link | | :--- | :--- | - | **Preview URL** | [${url}](${url}) | - | **Branch Alias** | [${alias}](${alias}) | - - *Commit: ${context.sha}*`; + | **Preview URL** | [${previewUrl}](${previewUrl}) | + | **Branch** | \`${branch}\` | + + *Commit: ${context.sha}* + + > Note: Preview deployments create a version without affecting production. The URL follows the pattern: \`-codeink.jorgeflorentinomarbe.workers.dev\``; github.rest.issues.createComment({ issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, body: body - }) \ No newline at end of file + }) diff --git a/README.md b/README.md index 39a6298..9c7cab6 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,34 @@ +## Development + +### Prerequisites + +- [Bun](https://bun.sh) installed on your system + +### Local Development + +```bash +# Clone the repository +git clone https://github.com/jorgefl8/codeink.git +cd codeink + +# Install dependencies +bun install + +# Start development server +bun dev +``` + +The development server will start at `http://localhost:4321` + +### Build for Production + +```bash +bun run build +``` + ## License This project is licensed under the MIT License. See the [LICENSE](https://github.com/jorgeifl8/codeink/blob/main/LICENSE) file for details. \ No newline at end of file diff --git a/wrangler.toml b/wrangler.toml new file mode 100644 index 0000000..3700cfb --- /dev/null +++ b/wrangler.toml @@ -0,0 +1,6 @@ +name = "codeink" +compatibility_date = "2026-02-11" +preview_urls = true + +[assets] +directory = "./dist"