Chance favors the prepared mind.
-
GitHub Pages
build FOSSA Status -
Tencent COS
构建状态
-
Email: eallions@gmail.com
Keybase:keybase://private/eallion/eallion.com
Coding.net: https://e.coding.net/eallion/eallion.com/hugo.git
码云 Gitee: https://gitee.com/eallion/eallion.com.git
阿里云 Codeup: https://codeup.aliyun.com/eallion/hugo.git
腾讯工蜂: https://git.code.tencent.com/eallion/eallion.com.git
(削除) 国内:通过阿里云云效 Codeup & Flow 部署至:阿里云 OSS + CDN (削除ここまで)(2019年12月20日)(削除) 国内:通过 Coding 部署至:Gitee pages (削除ここまで)(削除) 国内:通过 Coding 部署至:Coding pages (削除ここまで)(削除) 国内:通过 GitHub Action 部署至腾讯云 CloudBase (削除ここまで)(2020年08月12日)(削除) 境外:通过 GitHub Action 部署至 GitHub Pages (削除ここまで)(2020年08月12日)
default branch: main
remote url 传递 id:token 免输各个 git 仓库的账号密码
git remote set-url --add --push origin https://id:token@github.com/eallion/eallion.com.git
git remote set-url --add --push origin https://id:token@e.coding.net/eallion/eallion.com/hugo.git
git remote set-url --add --push origin https://id:token@git.code.tencent.com/eallion/eallion.com.git
git remote set-url --add --push origin https://id:token@gitee.com/eallion/eallion.com.git
git remote set-url --add --push origin https://id:token@codeup.aliyun.com/id/eallion/hugo.git
git remote set-url --add --push origin keybase://private/eallion/eallion
cd ../eallion_gohugo_????
dpkg -i hugo_latest.deb
cd ../eallion_hugo_????
hugo --cleanDestinationDir --forceSyncStatic --gc --ignoreCache --minify
find -maxdepth 1 -type d -not -name public -not -name "." -exec rm -rf {} \;
find -maxdepth 1 -type f -exec rm {} \;
rm -rf public/images
rm -rf public/photos
pipeline {
agent any
stages {
stage('检出') {
steps {
checkout([
$class: 'GitSCM',
branches: [[name: env.GIT_BUILD_REF]],
userRemoteConfigs: [[
url: env.GIT_REPO_URL,
credentialsId: env.CREDENTIALS_ID
]]])
}
}
stage('Build Hugo') {
agent {
docker {
image 'envimate/hugo:latest'
reuseNode true
}
}
steps {
sh 'hugo --cleanDestinationDir --forceSyncStatic --gc --ignoreCache --minify'
}
}
stage('上传到 COS Bucket') {
steps {
sh 'coscmd config -a ${COS_SECRET_ID} -s ${COS_SECRET_KEY} -b ${COS_BUCKET_NAME} -r ${COS_BUCKET_REGION} -m 30'
sh 'coscmd upload -r ${COS_UPLOAD_FROM_PATH} /'
echo '部署成功!'
}
}
}
}
https://github.com/marketplace/actions/tencent-cloudbase-github-action
- name: Deploy to Tencent CloudBase
id: deployStatic
uses: TencentCloudBase/cloudbase-action@v1.1.1
with:
secretId: ${{ secrets.CLOUDBASE_SECRET_ID }}
secretKey: ${{ secrets.CLOUDBASE_SECRET_KEY }}
envId: ${{ secrets.CLOUDBASE_ENV_ID }}
staticSrcPath: public
- name: Deploy to OSS
uses: saltbo/uptoc@master
with:
driver: oss
region: cn-shanghai
bucket: ${{ secrets.bucket }}
exclude: public/images,public/photos
dist: public
env:
UPTOC_UPLOADER_AK: ${{ secrets.ACCESS_KEY_ID }}
UPTOC_UPLOADER_SK: ${{ secrets.ACCESS_KEY_SECRET }}
- name: Build Gitee Pages
uses: yanglbme/gitee-pages-action@master
with:
gitee-username: ${{ secrets.GITEE_USERNAME }}
gitee-password: ${{ secrets.GITEE_PASSWORD }}
gitee-repo: eallion/eallion
branch: gh-pages
# directory: /
https: true
当没有新提交时, 通过 push empty commit 运行 GitHub Actions
git commit --allow-empty -m "Rerun GitHub Acions"
git push
- 生成新文章
hugo new posts/daily/new_title.md
- 修改 Front matter:
categories删除多余的分类tags按需添加draft: true改为:draft: falseslug按需修改
- 写文章
通过 Typora 或 VSCode 编辑文章
- Push & auto deploy:
git add .
git commit -m "Post new_title"
git push
- 本地调试(
(削除) Web Server (削除ここまで))
hugo server -w -D -p 8080 -t hello-friend
hugo server把 Hugo 当作 Web 服务器,而非构建静态网页-w有文件变化立即刷新(默认开启)-D构建草稿,撰写新文章时很有用-p 8080端口+端口号(默认 1313)-t hello-friend使用 hello-friend 主题hugo --help查看所有命令
- 本地构建
hugo --cleanDestinationDir --forceSyncStatic --gc --ignoreCache --minify
--cleanDestinationDir构建前先清理目标文件夹,即 public--forceSyncStatic强制同步 static 文件夹--gc构建后执行一些清理任务(删除掉一些没用的缓存文件)--ignoreCache构建时忽略缓存--minify压缩网页代码hugo --help查看所有命令
- 本地部署至腾讯云 CloudBase
cd gpm/github.com/eallion/eallion.com
tcb hosting deploy public / -e TCB-envID
public本地 Hugo 静态网页文件(能过第 6 步的命令构建)/CloudBase 静态托管的目录,一般部署至根目录/-e TCB-envIDCloudBase 的环境 ID
Update: 2021年01月05日 使用 Hugo 自带的 Asset minification
(削除) Update: 2020年12月18日 从腾讯云换到了 jsDelivr (削除ここまで)
{{ $maincss := resources.Get "css/style.css" | resources.Minify | resources.Fingerprint "sha256" }}
<link rel="stylesheet" href="{{ $maincss.RelPermalink }}" integrity="{{ $maincss.Data.Integrity }}" crossorigin="anonymous">
新方式:(CDN URL 不变)
将cdn.jsdelivr.net改为 purge.jsdelivr.net,在浏览器中请求即可刷新 CDN。
旧方法:
通过打 Tag 的方式刷新 jsDelivr 的 CDN
tag对应commit
git tag vX.X.X
git push origin vX.X.X
# git push origin --tags # 推送所有 Tags
因为 jsDelivr 2020年08月15日 的新政策,现在没有用 GitHub + jsDelivr 当图床了。
现在写博客添加图片,需要手动添加图片地址。
原方法依然可用,注意图片URL即可。
- 图片存放目录:
Hugo 目录的
static/images/文件夹下(可按年月分类)。
- 文章中引用的图片 URL:
https://eallion.com/images+图片路径和名称
- 如:
https://eallion.com/images/2020/05/ubuntu2004.jpg
- 照片存放目录:
照片需要上传至腾讯云COS。但是本博客没有开启相册页面,无须操作。
(削除) Hugo 目录的static/photos/文件夹下,相册页面会自动索引。 (削除ここまで)
GLWT(祝你好运)公共许可证
版权所有(C)每个人,除了作者
任何人都被允许复制、分发、修改、合并、销售、出版、再授权或
任何其它操作,但风险自负。
作者对这个项目中的代码一无所知。
代码处于可用或不可用状态,没有第三种情况。
祝你好运公共许可证
复制、分发和修改的条款和条件
0 :在不导致作者被指责或承担责任的情况下,你可以做任何你想
要做的事情。
无论是在合同行为、侵权行为或其它因使用本软件产生的情形,作
者不对任何索赔、损害承担责任。
祝你好运及一帆风顺。