问题描述
发现自己博客2023-08月后就没更新了。其实我一直有写博客。是Hugo Deploy的workflow所依赖的Ubuntu版本不支持了。
原来如下:
1
2
3
4
5
6
7
8
9
10
| Run hugo --minify
Start building sites …
hugo v0.125.7-b1d808bc373f53ad37c8966bb02a6aea095db5f8 linux/amd64 BuildDate=2024-05-08T14:46:24Z VendorInfo=gohugoio
WARN deprecated: .Site.RSSLink was deprecated in Hugo v0.114.0 and will be removed in a future release. Use the Output Format's Permalink method instead, e.g. .OutputFormats.Get "RSS".Permalink
ERROR TOCSS: failed to transform "/sass/main.scss" (text/x-scss). Check your Hugo installation; you need the extended version to build SCSS/SASS with transpiler set to 'libsass'.: this feature is not available in your current Hugo version, see https://goo.gl/YMrWcn for more information
WARN The author key in site configuration is deprecated. Use params.author.name instead.
Total in 1807 ms
Error: error building site: TOCSS: failed to transform "/sass/main.scss" (text/x-scss). Check your Hugo installation; you need the extended version to build SCSS/SASS with transpiler set to 'libsass'.: this feature is not available in your current Hugo version, see https://goo.gl/YMrWcn for more information
Error: Process completed with exit code 1.
|
Fix Hugo Github workflows config.yml issue
参考配置文件:https://github.com/actions/starter-workflows/blob/main/pages/hugo.yml
Github push failed
1
2
3
4
5
6
7
| Push the commit or tag
/usr/bin/git push origin source
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Error: Action failed with "The process '/usr/bin/git' failed with exit code 128"
|
update deploy key, 三年前的ACTIONS_DEPLOY_KEY 需要更新了。
https://github.com/hustbill/pdca-blog/settings/secrets/actions
参考这个文章: https://docs.github.com/en/actions/security-guides/using-secrets-in-github-actions
需要用personal_token , 不能用github_token , github_token 不具备从pdc_blog repo 向外部repo hustbill.github.io写的能力。
personal_token生成参考了Gemini
Use case:
A GitHub Free Plan account cannot use the GitHub Pages in a private repository. To make your source contents private and deploy it with the GitHub Pages, you can deploy your site from a private repository to a public repository using this option.
Create Personal token to access external repository
Note that GITHUB_TOKEN
has no permission to access to external repositories. Please create a personal access token and set it to personal_token
like personal_token: ${{ secrets.PERSONAL_TOKEN }}
.
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
|
The error message indicates that the peaceiris/actions-gh-pages@v4 action is encountering an issue with the provided GitHub token. The generated token (likely named GITHUB_TOKEN) doesn't have permissions to push to an external repository (which GitHub Pages essentially is). Here's how to fix this:
1. Choose the Right Authentication Method:
The action message suggests two alternative authentication methods:
deploy_key: This refers to using an SSH key for deployment. We've already discussed this approach in previous solutions.
personal_token: This is the recommended approach for most cases. A personal access token created specifically with permissions to push to your GitHub Pages repository is required.
2. Generate a Personal Access Token:
Go to your GitHub account settings: https://github.com/settings/tokens
Click on "Generate a new token."
Give your token a descriptive name (e.g., "Hugo-Deployment").
Select the scopes necessary for deployment. At minimum, you'll need the "repo" scope with "push" access. Granting additional scopes might be necessary depending on your workflow's needs. However, it's recommended to keep permissions minimal for security reasons.
Click on "Generate token" and copy the generated token.
3. Configure the Action:
There are two ways to provide the personal access token to the action:
Workflow Secrets: Store the token as a secret in your GitHub repository settings. Then, reference the secret name within your workflows/pages.yml file using the ${{ secrets.<SECRET_NAME> }} syntax. Replace <SECRET_NAME> with the actual name you assigned to the secret.
Environment Variables: Set an environment variable named GITHUB_TOKEN with the value of your personal access token within your workflow file. However, this approach exposes the token in the workflow logs, which is less secure than using secrets.
4. Update Workflow File:
Modify your workflows/pages.yml file to use the chosen authentication method (either deploy key or personal access token). Refer to the peaceiris/actions-gh-pages@v4 action documentation for specific syntax and configuration options related to authentication: https://github.com/peaceiris/actions-gh-pages#readme.
|
1
2
3
4
5
| - name: Deploy
uses: peaceiris/actions-gh-pages@v4
with:
personal_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public
|
截止 1:11 AM 5/12 值得吗? 我觉得值得。
以后坚持写日记 ,打卡。 用自己的Macbook 2015 坚持发光发热。
记住:不要盲目瞎尝试,读文档先!
https://github.com/peaceiris/actions-gh-pages?tab=readme-ov-file#readme 已经讲得很清楚了。Deploy相关的参数都描述清楚了。 v3 和v4的input 差距有些,特别是大小写敏感。
感言
继续调试Hugo Workflows 比较花费时间。 不知道10年后,我是否还有精力和兴趣来更新这个Hugo workflow。
也不知道GitHub是否还存在。 走一步看一步吧。
好难弄啊!! 🤯
用Github 提供的workflow 配置- Hugo
添加了新的worklfow 试试
https://github.com/hustbill/pdca-blog/blob/master/.github/workflows/hugo.yml
delete hustbill.github.io repo gh-pages
branch
1
| git push origin -d gh-pages
|
先描述问题, 然后再寻找方法,去解决问题。
每次pdca-blog 仓库master branch有更新,会触发hustbill.github.io 的内置 package-build- deploy 任务,然后把branch gh-pages上的内容部署到Github pages上。 然后用http://hustbill.github.io 来访问。
解决了gh-pages branch上只有文件,无其他文件生成的问题。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
| - name: Build with Hugo
run: hugo --minify
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./public
# Deployment job
- name: Deploy to GitHub Pages
id: deployment
uses: peaceiris/actions-gh-pages@v4 # https://github.com/peaceiris/actions-gh-pages#readme
with:
disable_nojekyll: true # This line disables .nojekyll creation
deploy_key: ${{ secrets.ACTIONS_DEPLOY_PRIVATE_KEY }}
# personal_token: ${{ secrets.PERSONAL_TOKEN }}
external_repository: hustbill/hustbill.github.io
publish_branch: gh-pages # default: gh-pages
publish_dir: ./public
# allow_empty_commit: false
keep_files: true
commit_message: ${{ github.event.head_commit.message }}
# force_orphan: true # This allows you to make your publish branch with only the latest commit.
|
Notes
文章作者
Hustbill billyzhang2010@gmail.com
上次更新
2024-05-11