基本上我有一个 Lektor 项目,我正在尝试使用 Github Actions 部署到 Github Pages
但是发布总是失败并显示此消息致命:无法读取“https://github.com”的用户名:没有这样的设备或地址
这是完整的日志:
Run lektor deploy ghpages-https
/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/lektor/publisher.py:657: DeprecationWarning: 'werkzeug.urls.url_parse' is deprecated and will be removed in Werkzeug 3.0. Use 'urllib.parse.urlsplit' instead.
url = urls.url_parse(str(target))
/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/werkzeug/urls.py:545: DeprecationWarning: 'werkzeug.urls.URL' is deprecated and will be removed in Werkzeug 3.0. Use the 'urllib.parse' library instead.
return result_type(scheme, netloc, url, query, fragment)
Deploying to ghpages-https
Build cache: /home/runner/.cache/lektor/builds/1e169503b08805b6925804c56b34ca69
Target: ghpages+https://dzc0d3r/codeblog
hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint:
hint: git config --global init.defaultBranch <name>
hint:
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint:
hint: git branch -m <name>
Initialized empty Git repository in /home/runner/work/codeblog/codeblog/temp/.deploytempbbbozlcm/scratch/.git/
From https://github.com/dzc0d3r/codeblog
* [new branch] gh-pages -> origin/gh-pages
/opt/hostedtoolcache/Python/3.11.3/x64/lib/python3.11/site-packages/werkzeug/urls.py:170: DeprecationWarning: 'werkzeug.urls.url_decode' is deprecated and will be removed in Werkzeug 2.4. Use 'urllib.parse.parse_qs' instead.
return url_decode(self.query, *args, **kwargs)
fatal: could not read Username for 'https://github.com': No such device or address
Done!
publish.yml
文件:
name: Publish
on:
push:
branches:
- main
jobs:
publish:
name: Publish site
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: "3.X"
- uses: actions/cache@v2
with:
key: ${{ github.ref }}
path: .cache
- name: Install dependencies
run: |
pip install --upgrade pip
pip install --upgrade setuptools
pip install -r requirements.txt
- name: Build site
run: |
lektor plugins reinstall
lektor build --no-prune
- name: Publish site
env:
LEKTOR_DEPLOY_USERNAME: ${{ secrets.LEKTOR_DEPLOY_USERNAME }}
LEKTOR_DEPLOY_PASSWORD: ${{ secrets.LEKTOR_DEPLOY_PASSWORD }}
run: |
lektor deploy ghpages-https
这是codeblog.lektorproject
:
[project]
name = codeblog
url = https://dzc0d3r.github.io/codeblog/
[servers.ghpages]
target = ghpages://dzc0d3r/codeblog
[servers.ghpages-https]
target = ghpages+https://dzc0d3r/codeblog
[packages]
lektor-minify = 1.2
lektor-disqus-comments = 0.4.1
lektor-tags = 0.3
任何想法、帮助、分步指南将不胜感激
最佳答案
你们有 2FA 吗? lektor documentation指出如果您启用了 2 因素身份验证,则需要 personal access token而不是使用 HTTPS 时的普通用户名和密码。
如果我没记错的话 lektor website本身是用 lektor 构建的,托管在 GitHub Pages 上并使用 GitHub Actions 部署,所以你可以看看他们的 workflow和 .lektorproject
文件以获取一些灵感。
在他们的工作流程中,他们使用 GITHUB_TOKEN
secret 进行身份验证作为个人访问 token 。此 secret 会在每个 Actions 工作流程中自动创建以进行身份验证,并且可以使用 ${{ Secrets.GITHUB_TOKEN }}
关于python - 将 Github Actions 与 Lektor CMS 结合使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76248839/