Skip to content

Commit db536f1

Browse files
committed
增加GitHub Action构建
1 parent a98344a commit db536f1

File tree

1 file changed

+101
-0
lines changed

1 file changed

+101
-0
lines changed

.github/workflows/ci.yml

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
2+
name: GitHub Pages
3+
on:
4+
push:
5+
branches:
6+
- master
7+
jobs:
8+
deploy:
9+
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idruns-on
10+
runs-on: ubuntu-latest
11+
steps:
12+
# https://github.com/actions/checkout
13+
- name: Checkout 🛎️
14+
uses: actions/checkout@v3
15+
with:
16+
submodules: recursive
17+
fetch-depth: 0
18+
19+
# https://github.com/actions/setup-node
20+
- name: Setup Node.js 🕸
21+
uses: actions/setup-node@v3
22+
with:
23+
# https://github.com/nvm-sh/nvm#long-term-support
24+
node-version: 'lts/*'
25+
26+
# https://github.com/ruby/setup-ruby
27+
- name: Setup Ruby 💎
28+
uses: ruby/setup-ruby@v1
29+
with:
30+
ruby-version: 3.1
31+
32+
- name: Install AsciiDoctor 🐶
33+
run: |
34+
gem install asciidoctor
35+
gem install asciidoctor-diagram
36+
gem install asciidoctor-comment-links
37+
gem install rouge
38+
39+
- name: Install Graphviz 🐰
40+
run: |
41+
sudo apt update -y -m
42+
sudo apt install -y python3-pip
43+
# https://graphviz.org/
44+
sudo apt install -y graphviz
45+
# http://blockdiag.com/en/seqdiag/index.html
46+
pip3 install seqdiag
47+
# http://blockdiag.com/en/blockdiag/index.html
48+
pip3 install blockdiag
49+
# http://blockdiag.com/en/actdiag/index.html
50+
pip3 install actdiag
51+
# http://blockdiag.com/en/nwdiag/index.html
52+
pip3 install nwdiag
53+
# https://github.com/Deep-Symmetry/bytefield-svg
54+
npm install -g bytefield-svg
55+
# https://github.com/gtudan/bpmn-js-cmd
56+
npm install -g bpmn-js-cmd
57+
sudo apt -y install plantuml
58+
59+
- name: Run Hugo 🏗
60+
run: |
61+
asciidoctor -a toc=left -a stylesdir=assets/styles/ -a linkcss -r asciidoctor-multipage -r asciidoctor-comment-links -b multipage_html5 -D . index.adoc
62+
63+
- name: Add Reward Qrcode 💰
64+
run: |
65+
find . -name "*.html" | grep -v "preface.html" | xargs -I {} sed -i "s|<div id=\"content\">|<div id=\"content\"><div class=\"sect2\"><h3 id=\"_友情支持\">友情支持</h3><div class=\"paragraph\"><p>如果您觉得这个笔记对您有所帮助,看在D瓜哥码这么多字的辛苦上,请友情支持一下,D瓜哥感激不尽,😜</p></div><table class=\"tableblock frame-none grid-all stretch\"><colgroup><col style=\"width: 50%;\"><col style=\"width: 50%;\"></colgroup><tbody><tr><td class=\"tableblock halign-center valign-top\"><p class=\"tableblock\"><span class=\"image\"><img src=\"assets/images/alipay.png\" alt=\"支付宝\" width=\"85%\" title=\"支付宝\"></span></p></td><td class=\"tableblock halign-center valign-top\"><p class=\"tableblock\"><span class=\"image\"><img src=\"assets/images/wxpay.jpg\" alt=\"微信\" width=\"85%\" title=\"微信\"></span></p></td></tr></tbody></table><div class=\"paragraph\"><p>有些打赏的朋友希望可以加个好友,欢迎关注D 瓜哥的微信公众号,这样就可以通过公众号的回复直接给我发信息。</p></div><div class=\"paragraph\"><p><span class=\"image\"><img src=\"assets/images/wx-jikerizhi.png\" alt=\"wx jikerizhi\" width=\"98%\"></span></p></div><div class=\"admonitionblock tip\"><table><tbody><tr><td class=\"icon\"><i class=\"fa icon-tip\" title=\"Tip\"></i></td><td class=\"content\"><strong>公众号的微信号是: <code>jikerizhi</code></strong>。<em>因为众所周知的原因,有时图片加载不出来。 如果图片加载不出来可以直接通过搜索微信号来查找我的公众号。</em></td></tr></tbody></table></div></div>|" {}
66+
find . -name "*.html" | grep -v "index.html" | xargs -I {} sed -i 's|</head>|<script>var _hmt = _hmt \|\| [];(function () {var hm = document.createElement("script");hm.src = "https://hm.baidu.com/hm.js?ae79ae5854e141fa6c9a217b5dcf0e45";var s = document.getElementsByTagName("script")[0];s.parentNode.insertBefore(hm, s);})();</script></head>|' {}
67+
68+
- name: Compress Style 🍭
69+
run: |
70+
npm install cssnano-cli --location=global
71+
cd assets/styles/
72+
echo -e '\na{text-decoration:none;}p>code,strong>code{color: #d14 !important;background-color: #f5f5f5 !important;}' >> asciidoctor.css
73+
for f in `ls *.css`;
74+
do
75+
fn="${f%.*}.min.css";
76+
cssnano $f $fn;
77+
rm -rf $f;
78+
mv $fn $f
79+
done
80+
81+
- name: Rsync Deploy 🏹
82+
uses: burnett01/rsync-deployments@5.2
83+
with:
84+
switches: -avzr --delete --exclude=".*" ./assets ./*.html
85+
path: .
86+
remote_path: ${{ secrets.DEPLOY_PATH }}
87+
remote_host: ${{ secrets.DEPLOY_HOST }}
88+
remote_port: ${{ secrets.DEPLOY_PORT }}
89+
remote_user: ${{ secrets.DEPLOY_USER }}
90+
remote_key: ${{ secrets.DEPLOY_KEY }}
91+
92+
- name: Change Files Mod 🔐
93+
uses: appleboy/ssh-action@master
94+
with:
95+
host: ${{ secrets.DEPLOY_HOST }}
96+
port: ${{ secrets.DEPLOY_PORT }}
97+
username: ${{ secrets.DEPLOY_USER }}
98+
key: ${{ secrets.DEPLOY_KEY }}
99+
script: |
100+
cd ${{ secrets.DEPLOY_PATH }}
101+
sudo chmod -R 777 *

0 commit comments

Comments
 (0)