Toc
  1. Use Github Action Free CI/CD
Toc
0 results found
catzillaorz
零成本迁移CI/CD-Travis To Github Action
2023/02/05 CI/CD GitAction
Use Github Action Free CI/CD
  • Let’s go!
name: catzilla_githubio
run-name: ${{ github.actor }} is testing out GitHub Actions 🚀
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Cache node modules
uses: actions/cache@v3
with:
path: |
~/.npm
**/node_modules
key: ${{runner.os}}v1-npm-deps-${{ hashFiles('**/package-lock.json') }}
restore-keys: ${{runner.os}}v1-npm-deps-
- name: Use Node.js
uses: actions/checkout@v3
with:
node-version: '14.x'
- run: npm install -g hexo-cli
- run: git clone https://github.com/shixiaohu2206/hexo-theme-huhu.git themes/hexo-theme-huhu
- run: npm install
- run: npm install cheerio@=1.0.0-rc.3
#script: # 在构建阶段需要运行的命令,一条一行,类似的还有 before_script、after_script
- run: sed -i'' "s~landscape~hexo-theme-huhu/~" _config.yml #替换主题
- run: hexo clean
- run: hexo generate # Hexo 常规命令,执行清理和生成
- run: find -maxdepth 7 -mindepth 2 -name 'index.html' -exec sed -i'' "s~/cdn.jsdelivr.net/gh/catzillaorz/imgcdn/vsc_img/avatar2020-05-03.JPG~/cdn.jsdelivr.net/gh/catzillaorz/imgcdn/vsc_img/avatar2020-05-03.JPG~" {} + #替换logo
- run: find -maxdepth 7 -mindepth 2 -name 'index.html' -exec sed -i'' "s/raw.githubusercontent.com\/CatzillaOrz\/imgcdn\/master\//cdn.jsdelivr.net\/gh\/catzillaorz\/imgcdn\//g" {} + #替换logo
# find ./ -name '*12-29-*.md' -type f -exec sed -i'' -e "s/raw.githubusercontent.com\/CatzillaOrz\/imgcdn\/master\//cdn.jsdelivr.net\/gh\/catzillaorz\/imgcdn\//g" {} \;
# - find -maxdepth 2 -mindepth 2 -name 'index.html' -exec sed -i'' 's~~~' {} + #提交搜索引擎


#after_success: # script 阶段成功时执行,构建失败不会执行,其他同上
- run: git config --global user.name "catzillaorz"
- run: git config --global user.email "catzillaorz@outlook.com"
- run: sed -i'' "s~git@github.com:~https://${{vars.GITIO_REPO_TOKEN}}@github.com/~" _config.yml
- run: hexo deploy > /dev/null # 通过 Hexo 的 deploy 命令部署博客
  • enjoy
打赏
支付宝
微信
本文作者:catzillaorz
版权声明:本文首发于catzillaorz的博客,转载请注明出处!