Using Github Actions with Lektor CMS

huangapple go评论65阅读模式
英文:

Using Github Actions with Lektor CMS

问题

Sure, here's the translated portion:

基本上,我有一个Lektor项目,我正在尝试使用Github Actions来部署到Github Pages

但是,发布始终失败,并显示以下消息:“fatal: could not read Username for 'https://github.com': No such device or address”

以下是完整的日志:

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)
部署到ghpages-https
  构建缓存:/home/runner/.cache/lektor/builds/1e169503b08805b6925804c56b34ca69
  目标:ghpages+https://dzc0d3r/codeblog
  提示:将“master”用作初始分支的名称。此默认分支名称
  提示:可能会更改。要配置在所有新的存储库中使用的初始分支名称以抑制此警告,请调用:
  提示:
  提示:	git config --global init.defaultBranch <name>
  提示:
  提示:通常选择的名称而不是“master”的名称是“main”、“trunk”和
  提示:“development”。可以通过以下命令重命名刚创建的分支:
  提示:
  提示:	git branch -m <name>
  在/home/runner/work/codeblog/codeblog/temp/.deploytempbbbozlcm/scratch/.git/中初始化空的Git存储库。
  来自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
完成!

publish.yml文件:

name: 发布
on:
  push:
    branches:
      - main


作业:
  publish:
    name: 发布网站
    runs-on: ubuntu-latest
    步骤:
    - uses: actions/checkout@v3
    - name: 设置Python
      uses: actions/setup-python@v1
      with:
        python-version: "3.X"
    - uses: actions/cache@v2
      with:
        key: ${{ github.ref }}
        path: .cache
    - name: 安装依赖项
      run: |
        pip install --upgrade pip
        pip install --upgrade setuptools
        pip install -r requirements.txt
    - name: 构建网站
      run: |
        lektor plugins reinstall
        lektor build --no-prune


    - name: 发布网站
      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

希望这可以帮助您解决问题。

英文:

Basically i have a Lektor project, and i'm trying to to use Github Actions for deployment to Github Pages

But the publish always fail with this message fatal: could not read Username for 'https://github.com': No such device or address

Here is the complete log :

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!

The publish.yml file :

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

And this is the 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

Any idea, help, step by step guide would be appreciated

答案1

得分: 1

你是否开启了两步验证?lektor文档指出,如果启用了两步验证,使用HTTPS时需要使用个人访问令牌,而不是普通的用户名和密码。

如果我没有记错的话,lektor网站本身是用lektor构建的,托管在GitHub Pages上,并使用GitHub Actions进行部署,因此您可以查看它们的工作流程.lektorproject文件以获得一些灵感。

在它们的工作流程中,他们使用GITHUB_TOKEN密钥作为个人访问令牌进行身份验证。这个密钥会在每个Actions工作流中自动创建,用于身份验证目的,可以使用${{ secrets.GITHUB_TOKEN }}访问。

英文:

Do you have 2FA? The lektor documentation states that if you have 2-factor authentication enabled you need a personal access token instead of the normal username and password when using HTTPS.

If I'm not mistaken the lektor website itself is built with lektor, hosted on GitHub Pages and deployed with GitHub Actions, so you can take a look at their workflow and .lektorproject file for some inspiration.

In their workflow they authenticate using the GITHUB_TOKEN secret as the personal access token. This secret is automatically created in every Actions workflow for authentication purposes, and can be accessed using ${{ secrets.GITHUB_TOKEN }}

huangapple
  • 本文由 发表于 2023年5月15日 01:29:59
  • 转载请务必保留本文链接:https://go.coder-hub.com/76248839.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定