Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 35 additions & 15 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
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:
runs-on: ubuntu-latest
permissions:
contents: read
deployments: write
pull-requests: write
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -28,35 +30,53 @@ 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
if: github.event_name == 'pull_request'
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: \`<branch>-codeink.jorgeflorentinomarbe.workers.dev\``;

github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: body
})
})
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,34 @@

</div>

## 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.
6 changes: 6 additions & 0 deletions wrangler.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
name = "codeink"
compatibility_date = "2026-02-11"
preview_urls = true

[assets]
directory = "./dist"