diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml
new file mode 100644
index 0000000..7d36e41
--- /dev/null
+++ b/.github/workflows/deploy.yml
@@ -0,0 +1,32 @@
+name: Deploy Production
+
+on:
+ push:
+ branches:
+ - main
+
+jobs:
+ deploy:
+ runs-on: ubuntu-latest
+ name: Deploy Production
+ steps:
+ - uses: actions/checkout@v4
+
+ - uses: pnpm/action-setup@v4
+ with:
+ version: 9
+
+ - name: Setup Node.js
+ uses: actions/setup-node@v4
+ with:
+ node-version: "22"
+ cache: "pnpm"
+
+ - name: Install dependencies
+ run: pnpm install
+
+ - name: Deploy to Cloudflare Workers
+ uses: cloudflare/wrangler-action@v3
+ with:
+ apiToken: ${{ secrets.CF_API_TOKEN }}
+ command: deploy
diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml
new file mode 100644
index 0000000..58515eb
--- /dev/null
+++ b/.github/workflows/preview.yml
@@ -0,0 +1,32 @@
+name: Deploy Preview
+
+on:
+ push:
+ branches-ignore:
+ - main
+
+jobs:
+ deploy:
+ runs-on: ubuntu-latest
+ name: Deploy Preview
+ steps:
+ - uses: actions/checkout@v4
+
+ - uses: pnpm/action-setup@v4
+ with:
+ version: 9
+
+ - name: Setup Node.js
+ uses: actions/setup-node@v4
+ with:
+ node-version: "22"
+ cache: "pnpm"
+
+ - name: Install dependencies
+ run: pnpm install
+
+ - name: Deploy to Cloudflare Workers with Preview
+ uses: cloudflare/wrangler-action@v3
+ with:
+ apiToken: ${{ secrets.CF_API_TOKEN }}
+ command: deploy --env preview
diff --git a/README.md b/README.md
index 69ea880..e4ae9e6 100644
--- a/README.md
+++ b/README.md
@@ -4,31 +4,31 @@
-[][1]
-[][2]
-[][3]
-[][4]
-[][5]
-[][6]
-[][7]
-[][8]
-[][9]
-[][10]
-[][11]
-[][12]
-[][13]
-
-English | [简体中文][14]
+[][license]
+[][package-json]
+[][commits]
+[][actions]
+[][nodejs]
+[][typescript]
+[][prettier]
+[][make-pr]
+[][stars]
+[][forks]
+[][issues]
+[][repo]
+[][kofi]
+
+English | [简体中文][readme-zh]
A simple API service for retrieving GitHub user achievements information. Built with Cloudflare Workers.
## Live Demo
-- [https://github-achievements-api.wangrunlin.workers.dev][15]
+- [https://github-achievements-api.wangrunlin.workers.dev][demo]
## Deploy to Cloudflare Workers
-[][16]
+[][deploy]
## Features
@@ -123,13 +123,13 @@ Example error response:
Support this project by becoming a sponsor. Your logo will show up here with a link to your website.
-[][17]
+[][kofi-button]
-[Other sponsorship options][18]
+[Other sponsorship options][sponsor]
## Who's using GitHub Achievements API?
-Are you using this API? [Let us know][19] and we'll add your logo here!
+Are you using this API? [Let us know][new-issue] and we'll add your logo here!
## Local Development
@@ -158,17 +158,26 @@ pnpm test
## Deployment
-1. Login to Cloudflare
+This project uses GitHub Actions to automatically deploy to Cloudflare Workers:
-```bash
-pnpm dlx wrangler login
-```
+- Commits to non-main branches create preview deployments
+- Commits to main branch deploy to production
-2. Deploy Worker
+### Setup GitHub Secrets
-```bash
-pnpm deploy
-```
+To enable automatic deployments, you need to add the following secrets to your GitHub repository:
+
+1. Go to your repository on GitHub
+2. Navigate to Settings > Secrets and variables > Actions
+3. Add the following secrets:
+ - `CF_API_TOKEN`: Your Cloudflare API token with Workers permissions
+
+### How to get Cloudflare credentials
+
+1. **Cloudflare API Token**:
+ - Go to the [Cloudflare dashboard](https://dash.cloudflare.com/)
+ - Navigate to My Profile > API Tokens
+ - Create a new token with "Edit Workers" permissions
## Tech Stack
@@ -193,13 +202,13 @@ Issues and Pull Requests are welcome!
## Author
-[Leo Wang][20]
+[Leo Wang][author]
## Available Achievements
Here are all the achievements currently available on GitHub:
-[View more details about GitHub Achievements][21]
+[View more details about GitHub Achievements][github-achievements]
| Achievement | Name | Description | Max Tiers |
| -------------------------------------------------------------------------------------------------------------------------------------- | --------------------- | ------------------------------------------------------------------- | --------- |
@@ -217,39 +226,39 @@ Here are all the achievements currently available on GitHub:
Thanks to these awesome projects and resources:
-- [GitHub][22] - For providing the achievement system
-- [Cloudflare Workers][23] - For the serverless platform
-- [GitHub Achievements List][24] - For the comprehensive achievements documentation
-- [TypeScript][25] - For the typed JavaScript
-- [Vitest][26] - For the testing framework
-- [Wrangler][27] - For the development & deployment tool
-- [pnpm][28] - For the fast package manager
-
-[1]: https://github.com/wangrunlin/github-achievements-api/blob/main/LICENSE
-[2]: https://github.com/wangrunlin/github-achievements-api/blob/main/package.json
-[3]: https://github.com/wangrunlin/github-achievements-api/commits
-[4]: https://github.com/wangrunlin/github-achievements-api/actions
-[5]: https://nodejs.org
-[6]: https://www.typescriptlang.org/
-[7]: https://github.com/prettier/prettier
-[8]: https://makeapullrequest.com
-[9]: https://github.com/wangrunlin/github-achievements-api/stargazers
-[10]: https://github.com/wangrunlin/github-achievements-api/network
-[11]: https://github.com/wangrunlin/github-achievements-api/issues
-[12]: https://github.com/wangrunlin/github-achievements-api
-[13]: https://ko-fi.com/wangrunlin
-[14]: README_zh.md
-[15]: https://github-achievements-api.wangrunlin.workers.dev
-[16]: https://deploy.workers.cloudflare.com/?url=https://github.com/wangrunlin/github-achievements-api
-[17]: https://ko-fi.com/wangrunlin
-[18]: https://alin.run/sponsor
-[19]: https://github.com/wangrunlin/github-achievements-api/issues/new
-[20]: https://github.com/wangrunlin
-[21]: https://github.com/drknzz/GitHub-Achievements
-[22]: https://github.com
-[23]: https://workers.cloudflare.com
-[24]: https://github.com/drknzz/GitHub-Achievements
-[25]: https://www.typescriptlang.org
-[26]: https://vitest.dev
-[27]: https://developers.cloudflare.com/workers/wrangler/
-[28]: https://pnpm.io
+- [GitHub][github] - For providing the achievement system
+- [Cloudflare Workers][cloudflare-workers] - For the serverless platform
+- [GitHub Achievements List][github-achievements-list] - For the comprehensive achievements documentation
+- [TypeScript][typescript-site] - For the typed JavaScript
+- [Vitest][vitest] - For the testing framework
+- [Wrangler][wrangler] - For the development & deployment tool
+- [pnpm][pnpm] - For the fast package manager
+
+[license]: https://github.com/wangrunlin/github-achievements-api/blob/main/LICENSE
+[package-json]: https://github.com/wangrunlin/github-achievements-api/blob/main/package.json
+[commits]: https://github.com/wangrunlin/github-achievements-api/commits
+[actions]: https://github.com/wangrunlin/github-achievements-api/actions
+[nodejs]: https://nodejs.org
+[typescript]: https://www.typescriptlang.org/
+[prettier]: https://github.com/prettier/prettier
+[make-pr]: https://makeapullrequest.com
+[stars]: https://github.com/wangrunlin/github-achievements-api/stargazers
+[forks]: https://github.com/wangrunlin/github-achievements-api/network
+[issues]: https://github.com/wangrunlin/github-achievements-api/issues
+[repo]: https://github.com/wangrunlin/github-achievements-api
+[kofi]: https://ko-fi.com/wangrunlin
+[readme-zh]: README_zh.md
+[demo]: https://github-achievements-api.wangrunlin.workers.dev
+[deploy]: https://deploy.workers.cloudflare.com/?url=https://github.com/wangrunlin/github-achievements-api
+[kofi-button]: https://ko-fi.com/wangrunlin
+[sponsor]: https://alin.run/sponsor
+[new-issue]: https://github.com/wangrunlin/github-achievements-api/issues/new
+[author]: https://github.com/wangrunlin
+[github-achievements]: https://github.com/drknzz/GitHub-Achievements
+[github]: https://github.com
+[cloudflare-workers]: https://workers.cloudflare.com
+[github-achievements-list]: https://github.com/drknzz/GitHub-Achievements
+[typescript-site]: https://www.typescriptlang.org
+[vitest]: https://vitest.dev
+[wrangler]: https://developers.cloudflare.com/workers/wrangler/
+[pnpm]: https://pnpm.io
diff --git a/README_zh.md b/README_zh.md
index 1a4bc06..0254c32 100644
--- a/README_zh.md
+++ b/README_zh.md
@@ -4,31 +4,31 @@
-[][1]
-[][2]
-[][3]
-[][4]
-[][5]
-[][6]
-[][7]
-[][8]
-[][9]
-[][10]
-[][11]
-[][12]
-[][13]
-
-[English][14] | 简体中文
+[][license]
+[][package-json]
+[][commits]
+[][actions]
+[][nodejs]
+[][typescript]
+[][prettier]
+[][make-pr]
+[][stars]
+[][forks]
+[][issues]
+[][repo]
+[][kofi]
+
+[English][readme-en] | 简体中文
一个简单的 API 服务,用于获取 GitHub 用户的成就信息。基于 Cloudflare Workers 构建。
## 在线使用
-- [https://github-achievements-api.wangrunlin.workers.dev][15]
+- [https://github-achievements-api.wangrunlin.workers.dev][demo]
## 部署到 Cloudflare Workers
-[][16]
+[][deploy]
## 功能特点
@@ -123,13 +123,13 @@ GET https://.workers.dev/wangrunlin
成为赞助商来支持这个项目。您的 logo 将会出现在这里并链接到您的网站。
-[][17]
+[][kofi-button]
-[其他赞助方式][18]
+[其他赞助方式][sponsor]
## 谁在使用 GitHub Achievements API?
-您正在使用这个 API 吗?[告诉我们][19],我们会在这里添加您的 logo!
+您正在使用这个 API 吗?[告诉我们][new-issue],我们会在这里添加您的 logo!
## 本地开发
@@ -158,17 +158,27 @@ pnpm test
## 部署
-1. 登录到 Cloudflare
+本项目使用 GitHub Actions 自动部署到 Cloudflare Workers:
-```bash
-pnpm dlx wrangler login
-```
+- 向非主分支提交代码会创建预览部署
+- 向主分支提交代码会部署到生产环境
-2. 部署 Worker
+### 设置 GitHub Secrets
-```bash
-pnpm deploy
-```
+要启用自动部署,您需要在 GitHub 仓库中添加以下密钥:
+
+1. 前往您的 GitHub 仓库
+2. 导航到 Settings > Secrets and variables > Actions
+3. 添加以下密钥:
+ - `CF_API_TOKEN`:您的 Cloudflare API 令牌(需要 Workers 权限)
+
+### 如何获取 Cloudflare 凭据
+
+1. **Cloudflare API 令牌**:
+
+ - 前往 [Cloudflare 控制面板](https://dash.cloudflare.com/)
+ - 导航到 My Profile > API Tokens
+ - 创建一个具有"Edit Workers"权限的新令牌
## 技术栈
@@ -193,13 +203,13 @@ MIT
## 作者
-[Leo Wang][20]
+[Leo Wang][author]
## 可获得的成就
以下是目前 GitHub 上可获得的所有成就:
-[查看更多 GitHub 成就相关信息][21]
+[查看更多 GitHub 成就相关信息][github-achievements]
| 成就图标 | 名称 | 描述 | 最高等级 |
| -------------------------------------------------------------------------------------------------------------------------------------- | --------------------- | --------------------------------------- | -------- |
@@ -217,39 +227,39 @@ MIT
感谢这些优秀的项目和资源:
-- [GitHub][22] - 提供成就系统
-- [Cloudflare Workers][23] - 提供无服务器平台
-- [GitHub Achievements List][24] - 提供完整的成就文档
-- [TypeScript][25] - 提供类型化的 JavaScript
-- [Vitest][26] - 提供测试框架
-- [Wrangler][27] - 提供开发和部署工具
-- [pnpm][28] - 提供快速的包管理器
-
-[1]: https://github.com/wangrunlin/github-achievements-api/blob/main/LICENSE
-[2]: https://github.com/wangrunlin/github-achievements-api/blob/main/package.json
-[3]: https://github.com/wangrunlin/github-achievements-api/commits
-[4]: https://github.com/wangrunlin/github-achievements-api/actions
-[5]: https://nodejs.org
-[6]: https://www.typescriptlang.org/
-[7]: https://github.com/prettier/prettier
-[8]: https://makeapullrequest.com
-[9]: https://github.com/wangrunlin/github-achievements-api/stargazers
-[10]: https://github.com/wangrunlin/github-achievements-api/network
-[11]: https://github.com/wangrunlin/github-achievements-api/issues
-[12]: https://github.com/wangrunlin/github-achievements-api
-[13]: https://ko-fi.com/wangrunlin
-[14]: README.md
-[15]: https://github-achievements-api.wangrunlin.workers.dev
-[16]: https://deploy.workers.cloudflare.com/?url=https://github.com/wangrunlin/github-achievements-api
-[17]: https://ko-fi.com/wangrunlin
-[18]: https://alin.run/sponsor
-[19]: https://github.com/wangrunlin/github-achievements-api/issues/new
-[20]: https://github.com/wangrunlin
-[21]: https://github.com/drknzz/GitHub-Achievements
-[22]: https://github.com
-[23]: https://workers.cloudflare.com
-[24]: https://github.com/drknzz/GitHub-Achievements
-[25]: https://www.typescriptlang.org
-[26]: https://vitest.dev
-[27]: https://developers.cloudflare.com/workers/wrangler/
-[28]: https://pnpm.io
+- [GitHub][github] - 提供成就系统
+- [Cloudflare Workers][cloudflare-workers] - 提供无服务器平台
+- [GitHub Achievements List][github-achievements-list] - 提供完整的成就文档
+- [TypeScript][typescript-site] - 提供类型化的 JavaScript
+- [Vitest][vitest] - 提供测试框架
+- [Wrangler][wrangler] - 提供开发和部署工具
+- [pnpm][pnpm] - 提供快速的包管理器
+
+[license]: https://github.com/wangrunlin/github-achievements-api/blob/main/LICENSE
+[package-json]: https://github.com/wangrunlin/github-achievements-api/blob/main/package.json
+[commits]: https://github.com/wangrunlin/github-achievements-api/commits
+[actions]: https://github.com/wangrunlin/github-achievements-api/actions
+[nodejs]: https://nodejs.org
+[typescript]: https://www.typescriptlang.org/
+[prettier]: https://github.com/prettier/prettier
+[make-pr]: https://makeapullrequest.com
+[stars]: https://github.com/wangrunlin/github-achievements-api/stargazers
+[forks]: https://github.com/wangrunlin/github-achievements-api/network
+[issues]: https://github.com/wangrunlin/github-achievements-api/issues
+[repo]: https://github.com/wangrunlin/github-achievements-api
+[kofi]: https://ko-fi.com/wangrunlin
+[readme-en]: README.md
+[demo]: https://github-achievements-api.wangrunlin.workers.dev
+[deploy]: https://deploy.workers.cloudflare.com/?url=https://github.com/wangrunlin/github-achievements-api
+[kofi-button]: https://ko-fi.com/wangrunlin
+[sponsor]: https://alin.run/sponsor
+[new-issue]: https://github.com/wangrunlin/github-achievements-api/issues/new
+[author]: https://github.com/wangrunlin
+[github-achievements]: https://github.com/drknzz/GitHub-Achievements
+[github]: https://github.com
+[cloudflare-workers]: https://workers.cloudflare.com
+[github-achievements-list]: https://github.com/drknzz/GitHub-Achievements
+[typescript-site]: https://www.typescriptlang.org
+[vitest]: https://vitest.dev
+[wrangler]: https://developers.cloudflare.com/workers/wrangler/
+[pnpm]: https://pnpm.io
diff --git a/wrangler.toml b/wrangler.toml
new file mode 100644
index 0000000..fc6ea76
--- /dev/null
+++ b/wrangler.toml
@@ -0,0 +1,6 @@
+name = "github-achievements-api"
+main = "src/index.ts"
+compatibility_date = "2025-02-27"
+
+[env.preview]
+name = "github-achievements-api-preview"
\ No newline at end of file