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
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 }}