新域名新气象
2022年6月29日
之前把站放在谷歌云上,但是后来谷歌云薅不动了,导致网站一直处于停摆状态,这段时间重新注册了个能支持备案的域名,再见了 theprue.one (准备卖了换点钱)。 新站采用了 vuepress 静态博客系统,源码挂在github上,使用action自动生成静态文件推送到良心云(腾讯云)的cos上面,因为cos支持静态网页,所以连服务器都省了,没有使用cdn速度也是刚刚的。良心云万岁!!!
下面记录一下vuepress的安装过程
安装vuepress
- 安装好node
- 安装好yarn
提示
node V16以上yarn好像只需要修改一个文件就可以了
mkdir vuepress-starter
cd vuepress-starter
git init
yarn init
yarn add -D vuepress@next
# 我使用得hero主题,所以就不用新建文件夹添加配置文件了
npm init vuepress-theme-hope@next [dir]
编写action的配置文件
在.github/workflows下建一个yml文件,这里提供一个模板
# This is a basic workflow to help you get started with Actions
name: Build and deploy
# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches:
- main
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# 这里填环境变量的名称,别搞错了
environment: github-pages
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
with:
ref: 'main'
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: "14"
# 缓存 node_modules
- name: Cache dependencies
uses: actions/cache@v2
id: yarn-cache
with:
path: |
**/node_modules
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
# 如果缓存没有命中,安装依赖,根据实际来改,也可以是npm,这里是用的yarn
- name: Install dependencies
if: steps.yarn-cache.outputs.cache-hit != 'true'
run: yarn
# 如果缓存没有命中,安装依赖,根据实际来改,也可以是npm,这里是用的yarn
- name: 构建静态文件
run: yarn docs:build
# # 上传到github的分支(如果你想用pages的话就取消注释这里)
# - name: Deploy
# uses: JamesIves/github-pages-deploy-action@releases/v3
# with:
# ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
# # 部署到 gh-pages 分支
# BRANCH: gh-pages
# # 部署目录为 VuePress 的默认输出目录,这里需要根据项目的目录进行修改
# FOLDER: dist
# deploy to tencent cos
- name: 部署到腾讯 COS
env:
SECRET_ID: ${{ secrets.TENCENT_SECRET_ID }}
SECRET_KEY: ${{ secrets.TENCENT_SECRET_KEY }}
BUCKET: ${{ secrets.TENCENT_COS_BUCKET }}
REGION: ap-chengdu
run: |
sudo pip install coscmd
coscmd config -a ${SECRET_ID} -s ${SECRET_KEY} -b ${BUCKET} -r ${REGION}
coscmd upload -rs --delete ./docs/.vuepress/dist/ / -f
一切ok