Github action code for deploy blog

in .github/workflows/action.yml: name:auto deployment# 名字自取on:push:branches:- master # 这里的意思是当 master 分支发生push的时候,运行下面的jobs,这里先改为github-actionsjobs:deploy:# 任务名自取runs-on:ubuntu-20.04 # 在什么环境运行任务steps:- uses:actions/checkout@v2 # 引用actions/checkout这个action,与所在的github仓库同名with:submodules:false# Fetch Hugo themes (true OR recursive) 获取submodule主题fetch-depth:0# Fetch all history for .GitInfo and .Lastmod- name:Setup Hugo # 步骤名自取uses:peaceiris/actions-hugo@v2 # hugo官方提供的action,用于在任务环境中获取hugowith:hugo-version:'0.89.2'# 获取最新版本的hugoextended:true- name:Buildrun:hugo --minify # 使用hugo构建静态网页- name:Deploy Githubuses:peaceiris/actions-gh-pages@v3 # 一个自动发布github pages的actionwith:# github_token: ${{ secrets.GITHUB_TOKEN }} 该项适用于发布到源码相同repo的情况,不能用于发布到其他repoexternal_repository:Andyliu92/Andyliu92.github.io # 发布到哪个repopersonal_token:${{ secrets.ACCESS_TOKEN }} # 发布到其他repo需要提供上面生成的personal access tokenpublish_dir:./public # 注意这里指的是要发布哪个文件夹的内容,而不是指发布到目的仓库的什么位置,因为hugo默认生成静态网页到public文件夹,所以这里发布public文件夹里的内容publish_branch:master # 发布到哪个branch- name:Upload Websiteuses:burnett01/rsync-deployments@5.1with:switches:-avzhpath:"./public/*"remote_path:"/home/ubuntu/www/Blogs/Personal"remote_host:"101.42.141.88"remote_port:"22"remote_user:ubunturemote_key:${{ secrets.COMFLUTER_TOKEN}}# - name: Upload Website# uses: zhenyuWang/Upload-File-Action@v1....

August 24, 2022 · 1 min · Andyliu

利用Git Hook实现服务器端文件提交大小限制

利用git hooks,在服务器端每次接收到push的时候进行文件信息检查,若超过限制则拒绝提交。 具体实现:在update hook中对提交的文件进行检查,利用git log命令查询所有新提交的分支,利用git cat-file 命令递归查询文件树、查询文件大小,若超限则返回1拒绝提交。 #!/bin/bash # # An example hook script to block unannotated tags from entering. # Called by "git receive-pack" with arguments: refname sha1-old sha1-new # # To enable this hook, rename this file to "update". # # Config # ------ # hooks.allowunannotated # This boolean sets whether unannotated tags will be allowed into the # repository. By default they won't be. # hooks.allowdeletetag # This boolean sets whether deleting tags will be allowed in the # repository....

May 7, 2022 · 3 min · Andyliu

Git Notes

Delete branchs local: git branch -d <localBranchName> remote: git push origin --delete <remoteBranchName>

December 22, 2021 · 1 min · Andyliu

Git large file versioning

Download git-lfs on https://git-lfs.github.com/, and run the installation package for windows. Once downloaded and installed, set up Git LFS for your user account by running:git lfs install. You only need to run this once per user account. In each Git repository where you want to use Git LFS, select the file types you’d like Git LFS to manage (or directly edit your .gitattributes). You can configure additional file extensions at anytime....

November 22, 2021 · 1 min · Andyliu