基本配置

起初按照官网的流程配置,fork和clone之后执行:

1
2
3
4
5
6
conda create -n runningpage python=3.11  # **python >= 3.11; node >= 20**
conda activate runningpage
pip install -r requirements.txt

npm install -g corepack && corepack enable && pnpm install
pnpm develop

进行到pnpm install这一步时,因为 corepack 的签名验证机制和 npm 注册表的密钥轮换,报错:

报错信息
1
2
3
4
5
6
7
8
9
10
11
12
E:\nodejs\node_modules\corepack\dist\lib\corepack.cjs:21535
if (key == null || signature == null) throw new Error(Cannot find matching keyid: ${JSON.stringify({ signatures, keys })});
^
Error: Cannot find matching keyid
at verifySignature (E:\nodejs\node_modules\corepack\dist\lib\corepack.cjs:21535:47)
at fetchLatestStableVersion (E:\nodejs\node_modules\corepack\dist\lib\corepack.cjs:21553:5)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async fetchLatestStableVersion2 (E:\nodejs\node_modules\corepack\dist\lib\corepack.cjs:21672:14)
at async Engine.getDefaultVersion (E:\nodejs\node_modules\corepack\dist\lib\corepack.cjs:22292:23)
at async Engine.executePackageManagerRequest (E:\nodejs\node_modules\corepack\dist\lib\corepack.cjs:22390:47)
at async Object.runMain (E:\nodejs\node_modules\corepack\dist\lib\corepack.cjs:23096:5)
Node.js v20.17.0

建议直接跳过 corepack,使用 npm 安装 pnpm:

1
2
3
4
5
6
7
8
# 禁用 corepack
corepack disable

# 直接用 npm 安装 pnpm
npm install -g pnpm@latest

# 然后使用 pnpm 安装项目依赖
pnpm install

成功。

pnpm develop完毕后hold on,进入http://localhost:5173/查看,发现是官网第一个展示的默认running page;进入下一步。

个性化

必要:个人信息和TOKEN更改

  • mapbox token:被狠狠制裁了,可用Proton Mail的方法试试(记得用ipad进行mapbox的注册操作);我因为操作太频繁被Proton Mail封禁第三方平台的注册了(Your Proton account is currently restricted from registering on third-party services)。

  • keep secrets:

1
python run_page/keep_sync.py [phone_number] [secret] --with-gpx 

Github repo

首先,好好读教程!!!读完总算部署成功了。下面粗略总结一下步骤:

  1. 前述的下载、安装和测试;
  2. 在src/static/site-metadata.ts中更改网址为自己的域名,并做个性化设置;
  3. 下载APP(如KEEP)数据到本地(华为运动健康可直接同步到KEEP);
  4. 首次构建和推送:
    命令行
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    D:
    cd github/running_page
    conda activate runningpage

    pnpm install
    pnpm build

    git remote add upstream [SSH of fork]
    git remote add origin [SSH of fork]

    git push origin master:gh-pages
  5. Server:我选择的是部署到Github Pages。下面是第一次手动发布的流程:
    1. 进入仓库的 “Settings -> GitHub Pages -> Source”,选择 “GitHub Actions”
    2. 进入仓库的 “Actions -> Workflows -> All Workflows”,选择左侧面板的 “Run Data Sync”,点击 “Run workflow”更新数据,触发 “Publish GitHub Pages” 工作流;
    3. 打开网站检查结果;
    4. 为 GitHub Actions 添加代码提交权限,访问仓库的 Settings > Actions > General页面,找到 Workflow permissions 的设置项,将选项配置为 Read and write permissions,支持 CI 将运动数据更新后提交到仓库中。
    5. 因为需要添加自定义域名于 GitHub Pages,需要修改 gh-pages.yml 中的 Build 模块,删除 ${{ github.event.repository.name }}改为run: PATH_PREFIX=/ pnpm build
    6. 修改 src/static/site-metadata.ts 中 siteUrl为自己的域名。
      注:5-6步修改的是下面提到的gh-pages分支的.github/workflows/gh-pages.yml。

Github action

设置好Github Action的权限之后,还需要改自动化分支:本地和远程都需要保持master和gh-pages两个分支,并且要按自己的需求更改文件。要求是:

  1. 每天24:00自动更新数据并构建、发布到gh-pages分支;
  2. master用于敷衍pull bot的自动拉取行为,且不能让master分支成功发布(因为会同步原repo的东西)。

下面给出更改例:

master 分支

用于从原仓库同步内容。

.github/workflows/gh-pages.yml
1
2
3
4
5
- uses: actions/checkout@v4
with:
ref: gh-pages
fetch-depth: 0
persist-credentials: false
.github/workflows/run_data_sync.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
name: Run Data Sync

on:
workflow_dispatch:
schedule:
- cron: '0 0 * * *'
push:
branches:
- gh-pages

# 10-46行略
sync:
name: Sync
runs-on: ubuntu-latest
# 添加条件确保只在gh-pages分支或通过手动/定时触发时运行
if: github.ref == 'refs/heads/gh-pages' || github.event_name == 'workflow_dispatch' || github.event_name == 'schedule'
outputs:
SAVE_DATA_IN_GITHUB_CACHE: ${{ steps.set_output.outputs.SAVE_DATA_IN_GITHUB_CACHE }}
DATA_CACHE_PREFIX: ${{ steps.set_output.outputs.DATA_CACHE_PREFIX }}
BUILD_GH_PAGES: ${{ steps.set_output.outputs.BUILD_GH_PAGES }}

steps:
- name: Checkout gh-pages branch
uses: actions/checkout@v4
with:
ref: gh-pages # 明确指定检出gh-pages分支
fetch-depth: 0
persist-credentials: true

# 230行左右
- name: Make month of life
if: env.GENERATE_MONTH_OF_LIFE == 'true'
env:
@@ -246,7 +250,7 @@ jobs:
git config --local user.name "GitHub Action"
git add .
git commit -m 'update new runs' || echo "nothing to commit"
git push origin HEAD:gh-pages || echo "nothing to push" # 明确推送到gh-pages分支

gh-pages分支

用于发布RunningPage页面。

.github/workflows/gh-pages.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
     - uses: actions/checkout@v4
with:
# if your default branches is not master, please change it here
repository: Y-Antares/running_page
ref: gh-pages
fetch-depth: 0
persist-credentials: false

@@ -94,9 +95,7 @@ jobs:
- name: Install dependencies
run: pnpm install
- name: Build
run: PATH_PREFIX=/ pnpm build

.github/workflows/run_data_sync.yml的修改与master分支一致。