利用阿里云 OSS部署静态网站
$ ping snowdreams1006.tech -t 3
PING snowdreams1006.tech.w.kunlunca.com (36.158.216.227): 56 data bytes
64 bytes from 36.158.216.227: icmp_seq=0 ttl=54 time=25.075 ms
64 bytes from 36.158.216.227: icmp_seq=1 ttl=54 time=22.077 ms
64 bytes from 36.158.216.227: icmp_seq=2 ttl=54 time=21.125 ms
--- snowdreams1006.tech.w.kunlunca.com ping statistics ---
3 packets transmitted, 3 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 21.125/22.759/25.075/1.683 ms
name: deploy to aliyun oss
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
# 切代码到 runner
- uses: actions/[email protected]
with:
submodules: true
# 下载 git submodule
- uses: srt32/[email protected]
with:
args: git submodule update --init --recursive
# 使用 node:10
- name: use Node.js 10.x
uses: actions/[email protected]
with:
node-version: 10.x
# npm install
- name: npm install and build
run: |
npm install
npm run build
env:
CI: true
# 设置阿里云OSS的 id/secret,存储到 github 的 secrets 中
- name: setup aliyun oss
uses: manyuanrong/[email protected]
with:
endpoint: oss-cn-beijing.aliyuncs.com
access-key-id: ${{ secrets.OSS_KEY_ID }}
access-key-secret: ${{ secrets.OSS_KEY_SECRET }}
- name: cp files to aliyun
run: ossutil cp -rf .vuepress/dist oss://shanyue-blog/
name: MainWorkflow
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: actions/[email protected]
with:
node-version: "12.x"
- name: Build Blog
run: |
npm install
npm install -g hexo-cli
hexo generate
- uses: manyuanrong/[email protected]
with:
# endpoint 可以去oss控制台上查看
endpoint: "oss-cn-hongkong.aliyuncs.com"
# 使用我们之前配置在secrets里面的accesskeys来配置ossutil
access-key-id: ${{ secrets.ACCESS_KEY_ID }}
access-key-secret: ${{ secrets.ACCESS_KEY_SECRET }}
- name: Deply To OSS
run: ossutil cp public oss://enok-blog/ -rf
name: blog
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: actions/[email protected]
with:
node-version: "12.x"
- name: Build blog
run: |
npm install -g gitbook-cli
gitbook install
gitbook build
- name: Upload blog
uses: appleboy/[email protected]
env:
HOST: ${{ secrets.HOST }}
USERNAME: ${{ secrets.USERNAME }}
KEY: ${{ secrets.KEY }}
with:
source: _book/*
target: ~/blog
rm: true
strip_components: 1
- name: Deploy blog
uses: appleboy/[email protected]
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.KEY }}
script: |
docker restart blog
- uses: manyuanrong/[email protected]
with:
endpoint: oss-cn-hangzhou.aliyuncs.com
access-key-id: ${{ secrets.ALI_ACCESS_KEY_ID }}
access-key-secret: ${{ secrets.ALI_ACCESS_KEY_SECRET }}
- name: Upload files to aliyun oss
run: ossutil cp -rf ./_book oss://snowdreams1006/
https://snowdreams1006.tech/
https://blog.snowdreams1006.cn/
https://snowdreams1006.tech/markdown/
https://blog.snowdreams1006.cn/markdown/
https://blog.snowdreams1006.cn/git/
https://blog.snowdreams1006.cn/git/base/about.html
https://blog.snowdreams1006.cn/git/base/install.html
https://blog.snowdreams1006.cn/git/server/private.html
^/(.*?)/$
/$1/index.html
break
Copy link