Skip to content

Commit 8d19b1f

Browse files
authored
feat: add CI/CD workflows and improve documentation (#5)
* feat: Add GitHub Actions and Cloudflare deployment configuration - Create Wrangler configuration for preview and production deployments - Add GitHub Actions workflow for preview deployments - Update README files with detailed deployment instructions and Cloudflare credential setup * feat: Add production deployment GitHub Actions workflow - Create deploy.yml for automatic production deployments - Update preview.yml to include deployment URL and commit comment - Add comment generation for deployment links in both workflows - Update wrangler.toml with a preview environment comment * chore: Update GitHub Actions commit comment action to v3 * chore: Simplify GitHub Actions deployment workflows * docs: Update README files with improved link references and TypeScript version
1 parent 246437a commit 8d19b1f

File tree

5 files changed

+221
-132
lines changed

5 files changed

+221
-132
lines changed

.github/workflows/deploy.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Deploy Production
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
deploy:
10+
runs-on: ubuntu-latest
11+
name: Deploy Production
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- uses: pnpm/action-setup@v4
16+
with:
17+
version: 9
18+
19+
- name: Setup Node.js
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: "22"
23+
cache: "pnpm"
24+
25+
- name: Install dependencies
26+
run: pnpm install
27+
28+
- name: Deploy to Cloudflare Workers
29+
uses: cloudflare/wrangler-action@v3
30+
with:
31+
apiToken: ${{ secrets.CF_API_TOKEN }}
32+
command: deploy

.github/workflows/preview.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Deploy Preview
2+
3+
on:
4+
push:
5+
branches-ignore:
6+
- main
7+
8+
jobs:
9+
deploy:
10+
runs-on: ubuntu-latest
11+
name: Deploy Preview
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- uses: pnpm/action-setup@v4
16+
with:
17+
version: 9
18+
19+
- name: Setup Node.js
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: "22"
23+
cache: "pnpm"
24+
25+
- name: Install dependencies
26+
run: pnpm install
27+
28+
- name: Deploy to Cloudflare Workers with Preview
29+
uses: cloudflare/wrangler-action@v3
30+
with:
31+
apiToken: ${{ secrets.CF_API_TOKEN }}
32+
command: deploy --env preview

README.md

Lines changed: 75 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,31 @@
44
<img src="https://github.githubassets.com/images/modules/profile/achievements/pull-shark-default.png" width="100" height="100" alt="Pull Shark Achievement" />
55
</p>
66

7-
[![License](https://img.shields.io/github/license/wangrunlin/github-achievements-api)][1]
8-
[![GitHub package.json version](https://img.shields.io/github/package-json/v/wangrunlin/github-achievements-api)][2]
9-
[![GitHub last commit](https://img.shields.io/github/last-commit/wangrunlin/github-achievements-api)][3]
10-
[![Test Status](https://img.shields.io/github/actions/workflow/status/wangrunlin/github-achievements-api/test.yml?label=test)][4]
11-
[![Node Version](https://img.shields.io/node/v/github-achievements-api)][5]
12-
[![TypeScript](https://img.shields.io/badge/TypeScript-5.5.2-blue.svg)][6]
13-
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)][7]
14-
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)][8]
15-
[![GitHub stars](https://img.shields.io/github/stars/wangrunlin/github-achievements-api)][9]
16-
[![GitHub forks](https://img.shields.io/github/forks/wangrunlin/github-achievements-api)][10]
17-
[![GitHub issues](https://img.shields.io/github/issues/wangrunlin/github-achievements-api)][11]
18-
[![Visitors](https://visitor-badge.laobi.icu/badge?page_id=wangrunlin.github-achievements-api)][12]
19-
[![Ko-fi](https://img.shields.io/badge/Ko--fi-Support-orange)][13]
20-
21-
English | [简体中文][14]
7+
[![License](https://img.shields.io/github/license/wangrunlin/github-achievements-api)][license]
8+
[![GitHub package.json version](https://img.shields.io/github/package-json/v/wangrunlin/github-achievements-api)][package-json]
9+
[![GitHub last commit](https://img.shields.io/github/last-commit/wangrunlin/github-achievements-api)][commits]
10+
[![Test Status](https://img.shields.io/github/actions/workflow/status/wangrunlin/github-achievements-api/test.yml?label=test)][actions]
11+
[![Node Version](https://img.shields.io/node/v/github-achievements-api)][nodejs]
12+
[![TypeScript](https://img.shields.io/badge/TypeScript-5.7.3-blue.svg)][typescript]
13+
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)][prettier]
14+
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)][make-pr]
15+
[![GitHub stars](https://img.shields.io/github/stars/wangrunlin/github-achievements-api)][stars]
16+
[![GitHub forks](https://img.shields.io/github/forks/wangrunlin/github-achievements-api)][forks]
17+
[![GitHub issues](https://img.shields.io/github/issues/wangrunlin/github-achievements-api)][issues]
18+
[![Visitors](https://visitor-badge.laobi.icu/badge?page_id=wangrunlin.github-achievements-api)][repo]
19+
[![Ko-fi](https://img.shields.io/badge/Ko--fi-Support-orange)][kofi]
20+
21+
English | [简体中文][readme-zh]
2222

2323
A simple API service for retrieving GitHub user achievements information. Built with Cloudflare Workers.
2424

2525
## Live Demo
2626

27-
- [https://github-achievements-api.wangrunlin.workers.dev][15]
27+
- [https://github-achievements-api.wangrunlin.workers.dev][demo]
2828

2929
## Deploy to Cloudflare Workers
3030

31-
[![Deploy to Cloudflare Workers](https://deploy.workers.cloudflare.com/button)][16]
31+
[![Deploy to Cloudflare Workers](https://deploy.workers.cloudflare.com/button)][deploy]
3232

3333
## Features
3434

@@ -123,13 +123,13 @@ Example error response:
123123

124124
Support this project by becoming a sponsor. Your logo will show up here with a link to your website.
125125

126-
[![Ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)][17]
126+
[![Ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)][kofi-button]
127127

128-
[Other sponsorship options][18]
128+
[Other sponsorship options][sponsor]
129129

130130
## Who's using GitHub Achievements API?
131131

132-
Are you using this API? [Let us know][19] and we'll add your logo here!
132+
Are you using this API? [Let us know][new-issue] and we'll add your logo here!
133133

134134
## Local Development
135135

@@ -158,17 +158,26 @@ pnpm test
158158

159159
## Deployment
160160

161-
1. Login to Cloudflare
161+
This project uses GitHub Actions to automatically deploy to Cloudflare Workers:
162162

163-
```bash
164-
pnpm dlx wrangler login
165-
```
163+
- Commits to non-main branches create preview deployments
164+
- Commits to main branch deploy to production
166165

167-
2. Deploy Worker
166+
### Setup GitHub Secrets
168167

169-
```bash
170-
pnpm deploy
171-
```
168+
To enable automatic deployments, you need to add the following secrets to your GitHub repository:
169+
170+
1. Go to your repository on GitHub
171+
2. Navigate to Settings > Secrets and variables > Actions
172+
3. Add the following secrets:
173+
- `CF_API_TOKEN`: Your Cloudflare API token with Workers permissions
174+
175+
### How to get Cloudflare credentials
176+
177+
1. **Cloudflare API Token**:
178+
- Go to the [Cloudflare dashboard](https://dash.cloudflare.com/)
179+
- Navigate to My Profile > API Tokens
180+
- Create a new token with "Edit Workers" permissions
172181

173182
## Tech Stack
174183

@@ -193,13 +202,13 @@ Issues and Pull Requests are welcome!
193202

194203
## Author
195204

196-
[Leo Wang][20]
205+
[Leo Wang][author]
197206

198207
## Available Achievements
199208

200209
Here are all the achievements currently available on GitHub:
201210

202-
[View more details about GitHub Achievements][21]
211+
[View more details about GitHub Achievements][github-achievements]
203212

204213
| Achievement | Name | Description | Max Tiers |
205214
| -------------------------------------------------------------------------------------------------------------------------------------- | --------------------- | ------------------------------------------------------------------- | --------- |
@@ -217,39 +226,39 @@ Here are all the achievements currently available on GitHub:
217226

218227
Thanks to these awesome projects and resources:
219228

220-
- [GitHub][22] - For providing the achievement system
221-
- [Cloudflare Workers][23] - For the serverless platform
222-
- [GitHub Achievements List][24] - For the comprehensive achievements documentation
223-
- [TypeScript][25] - For the typed JavaScript
224-
- [Vitest][26] - For the testing framework
225-
- [Wrangler][27] - For the development & deployment tool
226-
- [pnpm][28] - For the fast package manager
227-
228-
[1]: https://github.com/wangrunlin/github-achievements-api/blob/main/LICENSE
229-
[2]: https://github.com/wangrunlin/github-achievements-api/blob/main/package.json
230-
[3]: https://github.com/wangrunlin/github-achievements-api/commits
231-
[4]: https://github.com/wangrunlin/github-achievements-api/actions
232-
[5]: https://nodejs.org
233-
[6]: https://www.typescriptlang.org/
234-
[7]: https://github.com/prettier/prettier
235-
[8]: https://makeapullrequest.com
236-
[9]: https://github.com/wangrunlin/github-achievements-api/stargazers
237-
[10]: https://github.com/wangrunlin/github-achievements-api/network
238-
[11]: https://github.com/wangrunlin/github-achievements-api/issues
239-
[12]: https://github.com/wangrunlin/github-achievements-api
240-
[13]: https://ko-fi.com/wangrunlin
241-
[14]: README_zh.md
242-
[15]: https://github-achievements-api.wangrunlin.workers.dev
243-
[16]: https://deploy.workers.cloudflare.com/?url=https://github.com/wangrunlin/github-achievements-api
244-
[17]: https://ko-fi.com/wangrunlin
245-
[18]: https://alin.run/sponsor
246-
[19]: https://github.com/wangrunlin/github-achievements-api/issues/new
247-
[20]: https://github.com/wangrunlin
248-
[21]: https://github.com/drknzz/GitHub-Achievements
249-
[22]: https://github.com
250-
[23]: https://workers.cloudflare.com
251-
[24]: https://github.com/drknzz/GitHub-Achievements
252-
[25]: https://www.typescriptlang.org
253-
[26]: https://vitest.dev
254-
[27]: https://developers.cloudflare.com/workers/wrangler/
255-
[28]: https://pnpm.io
229+
- [GitHub][github] - For providing the achievement system
230+
- [Cloudflare Workers][cloudflare-workers] - For the serverless platform
231+
- [GitHub Achievements List][github-achievements-list] - For the comprehensive achievements documentation
232+
- [TypeScript][typescript-site] - For the typed JavaScript
233+
- [Vitest][vitest] - For the testing framework
234+
- [Wrangler][wrangler] - For the development & deployment tool
235+
- [pnpm][pnpm] - For the fast package manager
236+
237+
[license]: https://github.com/wangrunlin/github-achievements-api/blob/main/LICENSE
238+
[package-json]: https://github.com/wangrunlin/github-achievements-api/blob/main/package.json
239+
[commits]: https://github.com/wangrunlin/github-achievements-api/commits
240+
[actions]: https://github.com/wangrunlin/github-achievements-api/actions
241+
[nodejs]: https://nodejs.org
242+
[typescript]: https://www.typescriptlang.org/
243+
[prettier]: https://github.com/prettier/prettier
244+
[make-pr]: https://makeapullrequest.com
245+
[stars]: https://github.com/wangrunlin/github-achievements-api/stargazers
246+
[forks]: https://github.com/wangrunlin/github-achievements-api/network
247+
[issues]: https://github.com/wangrunlin/github-achievements-api/issues
248+
[repo]: https://github.com/wangrunlin/github-achievements-api
249+
[kofi]: https://ko-fi.com/wangrunlin
250+
[readme-zh]: README_zh.md
251+
[demo]: https://github-achievements-api.wangrunlin.workers.dev
252+
[deploy]: https://deploy.workers.cloudflare.com/?url=https://github.com/wangrunlin/github-achievements-api
253+
[kofi-button]: https://ko-fi.com/wangrunlin
254+
[sponsor]: https://alin.run/sponsor
255+
[new-issue]: https://github.com/wangrunlin/github-achievements-api/issues/new
256+
[author]: https://github.com/wangrunlin
257+
[github-achievements]: https://github.com/drknzz/GitHub-Achievements
258+
[github]: https://github.com
259+
[cloudflare-workers]: https://workers.cloudflare.com
260+
[github-achievements-list]: https://github.com/drknzz/GitHub-Achievements
261+
[typescript-site]: https://www.typescriptlang.org
262+
[vitest]: https://vitest.dev
263+
[wrangler]: https://developers.cloudflare.com/workers/wrangler/
264+
[pnpm]: https://pnpm.io

0 commit comments

Comments
 (0)