基本配置
起初按照官网 的流程配置,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 disable npm install -g pnpm@latest pnpm install
成功。
pnpm develop完毕后hold on,进入http://localhost:5173/查看,发现是官网第一个展示的默认running page;进入下一步。
个性化
必要:个人信息和TOKEN更改
1 python run_page/keep_sync.py [phone_number] [secret] --with -gpx
Github repo
首先,好好读教程 !!!读完总算部署成功了。下面粗略总结一下步骤:
前述的下载、安装和测试;
在src/static/site-metadata.ts中更改网址为自己的域名,并做个性化设置;
下载APP(如KEEP)数据到本地(华为运动健康可直接同步到KEEP);
首次构建和推送:命令行
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
Server:我选择的是部署到Github Pages。下面是第一次手动发布的流程:
进入仓库的 “Settings -> GitHub Pages -> Source”,选择 “GitHub Actions”
进入仓库的 “Actions -> Workflows -> All Workflows”,选择左侧面板的 “Run Data Sync”,点击 "Run workflow"更新数据,触发 “Publish GitHub Pages” 工作流;
打开网站检查结果;
为 GitHub Actions 添加代码提交权限,访问仓库的 Settings > Actions > General页面,找到 Workflow permissions 的设置项,将选项配置为 Read and write permissions,支持 CI 将运动数据更新后提交到仓库中。
因为需要添加自定义域名于 GitHub Pages,需要修改 gh-pages.yml 中的 Build 模块,删除 ${{ github.event.repository.name }}改为run: PATH_PREFIX=/ pnpm build;
修改 src/static/site-metadata.ts 中 siteUrl为自己的域名。
注:5-6步修改的是下面提到的gh-pages分支的.github/workflows/gh-pages.yml。
Github action
设置好Github Action的权限之后,还需要改自动化分支:本地和远程都需要保持master和gh-pages两个分支,并且要按自己的需求更改文件。要求是:
每天24:00自动更新数据并构建、发布到gh-pages分支;
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 sync: name: Sync runs-on: ubuntu-latest 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 fetch-depth: 0 persist-credentials: true - 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分支
用于发布RunningPage页面。
.github/workflows/gh-pages.yml
1 2 3 4 5 6 7 8 9 10 11 12 13 - uses: actions/checkout@v4 with : 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分支一致。