Skip to content

Commit 5181ec6

Browse files
authored
Merge pull request #94 from banzhe/main
update deploy doc
2 parents 242f3d1 + 6697976 commit 5181ec6

8 files changed

Lines changed: 100 additions & 31 deletions

docs/deploy.md

Lines changed: 47 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,59 @@
1-
## ~~Github Actions 一键部署~~
2-
> [!WARNING]
3-
> 由于 Cloudflare 的变动,一键部署功能暂时不可用。请使用命令部署。
1+
## GitHub Actions 部署
42

3+
### 1. 在 GitHub 上 Fork 本项目
54

6-
~~点击上面的按钮,按照 Cloudflare 的指引完成部署。~~
5+
先将本项目 Fork 到自己的 GitHub 账号下,后续的部署配置和工作流运行都在 Fork 后的仓库中完成。
6+
7+
### 2. 准备 Cloudflare 凭据
8+
9+
你需要在 Cloudflare 中准备以下两个 GitHub Actions Secrets:
10+
11+
- `CLOUDFLARE_ACCOUNT_ID`:Cloudflare 账号 ID,可参考 [Find account and zone IDs · Cloudflare Fundamentals docs](https://developers.cloudflare.com/fundamentals/account/find-account-and-zone-ids/) 获取。
12+
- `CLOUDFLARE_API_TOKEN`:用于 GitHub Actions 调用 Cloudflare API 的令牌,可在 [API 令牌 | Cloudflare](https://dash.cloudflare.com/profile/api-tokens) 页面创建。
713

814
> [!IMPORTANT]
9-
> ~~R2 存储桶是需要在 Cloudflare 面板上手动开通的功能,请开通后再进行部署或者失败后 re-run Github Actions~~
10-
> ~~仅需开通 R2 功能,不需要创建存储桶,存储桶会在部署时自动创建。~~
15+
> `R2` 功能需要先在 Cloudflare 面板中手动开通。请在开通后再进行部署;如果首次运行失败,开通后重新运行 GitHub Actions workflow 即可。
16+
> 这里只需要开通 `R2` 功能,不需要手动创建存储桶,部署时会自动创建 `web-archive` 存储桶。
1117
1218
> [!NOTE]
13-
> ~~创建令牌时,直接选择 `编辑 Cloudflare Workers` 模版,再手动添加 `D1 编辑` 权限。~~
19+
> 创建令牌时,直接选择 `编辑 Cloudflare Workers` 模板,再手动添加 `D1 编辑` 权限。
20+
> 账户资源选择“所有账户”,区域资源选择“所有区域”即可。
21+
22+
Cloudflare API 令牌权限配置可参考下图:
23+
24+
![Cloudflare API 令牌权限配置示意](https://raw.githubusercontent.com/ray-d-song/web-archive/main/docs/imgs/perm_zh.png)
25+
26+
### 3. 在 Fork 仓库中配置 GitHub Actions Secrets
27+
28+
进入 Fork 仓库的 `Settings -> Secrets and variables -> Actions` 页面,分别创建以下两个仓库 Secret:
29+
30+
- `CLOUDFLARE_ACCOUNT_ID`
31+
- `CLOUDFLARE_API_TOKEN`
1432

15-
![permissions](https://raw.githubusercontent.com/ray-d-song/web-archive/main/docs/imgs/perm_zh.png)
33+
Secrets 配置页面如下:
34+
35+
![GitHub Actions Secrets 配置页面](./imgs/actions_secrets.png)
36+
37+
### 4. 启用 GitHub Actions 并运行部署 workflow
38+
39+
进入 Fork 仓库的 `Actions` 页面;如果 GitHub 提示该 Fork 仓库的 Actions 尚未启用,先点击启用。
40+
41+
![启用 GitHub Actions](./imgs/actions_enable.png)
42+
43+
启用后,在工作流列表中选择 `Deploy`,再点击 `Run workflow` 手动触发部署。
44+
45+
![运行 Deploy workflow](./imgs/actions_deploy.png)
46+
47+
> [!IMPORTANT]
48+
> 部署后请尽快登录,首个登录的用户会被设置为管理员。
1649
17-
~~部署后请尽快登录,首个登录的用户会被设置为管理员。~~
50+
部署完成后,可以在 Cloudflare Workers 页面中找到服务的访问链接。访问时请使用不带 hash 的正式链接,不要复制带随机 hash 的预览链接。
51+
![Cloudflare Workers 页面中的访问链接位置](./imgs/cloudflare_workers_page.png)
1852

1953
## 命令部署
2054

21-
要求本地安装了 node 环境。
22-
命令部署时更新比较麻烦, 推荐实用 Github actions 部署。
55+
要求本地已安装 Node 环境。
56+
命令部署的更新流程相对更繁琐,推荐优先使用 GitHub Actions 部署。
2357
### 0. 下载代码
2458
在 release 页面下载最新的 service.zip,解压后在根目录执行后续操作。
2559

@@ -116,6 +150,6 @@ The project you specified does not exist: "web-archive". Would you like to creat
116150
117151
## 如何更新
118152
119-
使用 Github Actions 部署时,会自动创建一个 fork 仓库,更新只需要 sync fork 即可。
153+
使用 GitHub Actions 部署时,会自动创建一个 Fork 仓库,更新时只需要执行 Sync fork 即可。
120154
121-
命令部署时,需要下载最新的代码并手动更新。
155+
命令部署时,需要下载最新的代码并手动更新。

docs/en/deploy.md

Lines changed: 53 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,56 @@
1-
## ~~Github Actions~~
2-
3-
> [!WARNING]
4-
> Due to changes in Cloudflare, the one-click deployment feature is temporarily unavailable. Please use command deployment.
5-
6-
~~Click the button above, follow the instructions of Cloudflare to complete the deployment. )~~
7-
8-
>[!IMPORTANT]
9-
> ~~R2 storage bucket is a feature that needs to be manually enabled in the Cloudflare panel, please enable it before deployment or re-run Github Actions after failure.~~
10-
> ~~You only need to enable the R2 feature, no need to create a storage bucket, the storage bucket will be created automatically during deployment. ~~
11-
12-
> [!NOTE]
13-
> ~~When creating a token, select the `Edit Cloudflare Workers` template directly, and then manually add the `D1 Edit` permission.~~
14-
15-
![permissions](https://raw.githubusercontent.com/ray-d-song/web-archive/main/docs/imgs/perm.png)
16-
17-
~~Once deployed, please login as soon as possible, the first user to login will be set as the administrator.~~
18-
1+
## GitHub Actions Deployment
2+
3+
### 1. Fork this repository on GitHub
4+
5+
First, fork this repository to your own GitHub account. The deployment configuration and workflow runs will be done in your forked repository.
6+
7+
### 2. Prepare Cloudflare credentials
8+
9+
You need to prepare the following two GitHub Actions secrets in Cloudflare:
10+
11+
- `CLOUDFLARE_ACCOUNT_ID`: Your Cloudflare account ID. See [Find account and zone IDs - Cloudflare Fundamentals docs](https://developers.cloudflare.com/fundamentals/account/find-account-and-zone-ids/) for how to find it.
12+
- `CLOUDFLARE_API_TOKEN`: A token used by GitHub Actions to call the Cloudflare API. You can create it on the [API Tokens | Cloudflare](https://dash.cloudflare.com/profile/api-tokens) page.
13+
14+
> [!IMPORTANT]
15+
> The `R2` feature must be enabled manually in the Cloudflare dashboard before deployment. If the first workflow run fails because `R2` is not enabled yet, enable it and rerun the GitHub Actions workflow.
16+
> You only need to enable the `R2` feature. You do not need to create the bucket manually. The deployment will create the `web-archive` bucket automatically.
17+
18+
> [!NOTE]
19+
> When creating the token, choose the `Edit Cloudflare Workers` template first, then manually add the `D1 Edit` permission.
20+
> Set Account Resources to "All accounts" and Zone Resources to "All zones".
21+
22+
For reference, the Cloudflare API token permissions should look like this:
23+
24+
![Cloudflare API token permissions](https://raw.githubusercontent.com/ray-d-song/web-archive/main/docs/imgs/perm.png)
25+
26+
### 3. Configure GitHub Actions secrets in your fork
27+
28+
Go to `Settings -> Secrets and variables -> Actions` in your forked repository, then create these two repository secrets:
29+
30+
- `CLOUDFLARE_ACCOUNT_ID`
31+
- `CLOUDFLARE_API_TOKEN`
32+
33+
The Secrets configuration page looks like this:
34+
35+
![GitHub Actions secrets page](../imgs/actions_secrets.png)
36+
37+
### 4. Enable GitHub Actions and run the deployment workflow
38+
39+
Open the `Actions` page in your forked repository. If GitHub shows that Actions are disabled for the fork, enable them first.
40+
41+
![Enable GitHub Actions](../imgs/actions_enable.png)
42+
43+
After Actions are enabled, select the `Deploy` workflow from the workflow list, then click `Run workflow` to trigger deployment manually.
44+
45+
![Run the Deploy workflow](../imgs/actions_deploy.png)
46+
47+
> [!IMPORTANT]
48+
> After deployment, log in as soon as possible. The first user to log in will be assigned as the administrator.
49+
50+
After deployment finishes, you can find the service URL in the Cloudflare Workers dashboard. Use the formal URL without a hash, and do not copy the preview URL with a random hash.
51+
52+
![Service URL in the Cloudflare Workers dashboard](../imgs/cloudflare_workers_page_en.png)
53+
1954
## Command Deploy
2055

2156
Requirements: Local installation of node environment.

docs/imgs/actions_deploy.png

274 KB
Loading

docs/imgs/actions_enable.png

86.4 KB
Loading

docs/imgs/actions_secrets.png

263 KB
Loading

docs/imgs/actions_settings.png

146 KB
Loading
73.9 KB
Loading
44.5 KB
Loading

0 commit comments

Comments
 (0)