From 2b518b83ddc494e0d72f7e5be1ac30acfa59f6dc Mon Sep 17 00:00:00 2001 From: novlan1 <1576271227@qq.com> Date: Wed, 31 Jul 2024 00:47:48 +0800 Subject: [PATCH] chore: add workflow action --- .github/workflows/build-demo.yml | 56 ++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 .github/workflows/build-demo.yml diff --git a/.github/workflows/build-demo.yml b/.github/workflows/build-demo.yml new file mode 100644 index 0000000..ec72ea2 --- /dev/null +++ b/.github/workflows/build-demo.yml @@ -0,0 +1,56 @@ +# action 的名称 +name: Deploy GitHub Pages + +# 触发条件:在 push 到 main 分支后 +on: + push: + branches: + - master + +# 任务 +jobs: + build-and-deploy: + # 服务器环境:最新版 Ubuntu + runs-on: ubuntu-latest + strategy: + matrix: + node-version: [14] + steps: + # 拉取代码 + - name: Checkout + uses: actions/checkout@v2 + with: + persist-credentials: false + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v2 + with: + node-version: ${{ matrix.node-version }} + + - name: Cache .pnpm-store + uses: actions/cache@v1 + with: + path: ~/.pnpm-store + key: ${{ runner.os }}-node${{ matrix.node-version }}-${{ hashFiles('**/pnpm-lock.yaml') }} + + - name: Install pnpm + run: curl -f https://get.pnpm.io/v6.16.js | node - add --global pnpm@6 + + - name: Install Dependencies + run: pnpm install + + # 生成静态文件 + - name: Build + run: pnpm run docs:build + + # 部署到 GitHub Pages + - name: Deploy + # 使用别人写好的一个 action + uses: JamesIves/github-pages-deploy-action@releases/v3 + with: + # 这里的 ACCESS_TOKEN 名字需要和下文中的相对应 + ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }} + # 打包后的文件部署到哪个分支上 + BRANCH: docs + # 打包后的文件在哪里 + FOLDER: docs/.vuepress/dist