GitHub Actions for Hugo to OSS
发布时间 2021年5月30日 (更新时间 2023年12月12日) • 1 分钟 读完 • 145 字Blog 从 Hexo 迁移到 Hugo 后就很少在这上面写文章了,为了完成公众号的认证,前些日子一直在写公众号文章

Blog 从 Hexo 迁移到 Hugo 后就很少在这上面写文章了,为了完成公众号的认证,前些日子一直在写公众号文章,周五读了一篇文章感触颇深,讲得是“中年码农的困境”一种现状, 现在已经有很多三四十岁的码农了,很多公司对于中年的码农比较苛刻,由于他们的综合人力成本比较高,很容易被优化掉。
对于年轻的码农,作者给出的几条建议:
为了让自己的写的东西更好的沉淀下来,也算是对得起每月支付的域名费(codingbing.com),觉定再优化一下 Hugo 写完 Blog 的部署流程,之前的部署方式是:本地写完一篇文章,build 后,然后通过一个脚本上传到阿里云的 OSS,还算省心吧。
最近再玩 Github action,突然有个想法,为什么不自动完成这以流程呢。于是乎就有了以下流程:
使用的工具 peaceiris/actions-hugo,我的配置如下:
name: github pages
on:
push:
branches:
- main # Set a branch to deploy
- master
pull_request:
jobs:
deploy:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
with:
submodules: true # Fetch Hugo themes (true OR recursive)
fetch-depth: 0 # Fetch all history for .GitInfo and .Lastmod
- name: Setup Hugo
uses: peaceiris/actions-hugo@v2
with:
hugo-version: '0.83.1'
# extended: true
- name: Build
run: hugo --minify
# - name: Deploy
# uses: peaceiris/actions-gh-pages@v3
# if: github.ref == 'refs/heads/main'
# with:
# github_token: ${{ secrets.GITHUB_TOKEN }}
# publish_dir: ./public
- name: Deploy to OSS
uses: fangbinwei/aliyun-oss-website-action@v1
with:
accessKeyId: ${{ secrets.OSS_KEY_ID }}
accessKeySecret: ${{ secrets.OSS_KEY_SECRET }}
bucket: codingbing
# e.g. "oss-cn-shanghai.aliyuncs.com"
endpoint: oss-cn-shanghai.aliyuncs.com
folder: ./publicActions secrets 设置:
