generated from Zuoqiu-Yingyi/siyuan-plugin-template
-
-
Notifications
You must be signed in to change notification settings - Fork 0
95 lines (81 loc) · 2.75 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# 构建并部署 | Build and deploy
name: build
on:
workflow_dispatch:
push:
tags:
# REF https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet
- "v[0-9]+.[0-9]+.[0-9]+"
env:
PACKAGE_PATH: ./workspace/plugins/keepass
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
# Checkout
# REF https://github.com/marketplace/actions/checkout
- name: Checkout
uses: actions/checkout@v3
with:
## 将要拉取的仓库 | repository will to pull
repository: Zuoqiu-Yingyi/siyuan-packages-monorepo
# Install Node.js
# REF https://github.com/marketplace/actions/setup-node-js-environment
- name: Install Node.js
uses: actions/setup-node@v3
with:
## Node.js 版本号 | Node.js version
node-version: 20
## Node.js 源 | Node.js registry
registry-url: https://registry.npmjs.org
# Install pnpm
# REF https://github.com/marketplace/actions/setup-pnpm
- name: Install pnpm
uses: pnpm/action-setup@v2
id: pnpm-install
with:
## pnpm 版本号 | pnpm version
version: 8
## 是否安装 npm 包 | if install npm package?
run_install: false
# Get pnpm store directory
- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
# Setup pnpm cache
# REF https://github.com/marketplace/actions/cache
- name: Setup pnpm cache
uses: actions/cache@v3
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
# Install dependencies
- name: Install dependencies
run: |
cd $GITHUB_WORKSPACE
cd ./workspace
pnpm install
# Build package
- name: Build package
run: |
cd $GITHUB_WORKSPACE
cd $PACKAGE_PATH
echo "${{ secrets.KEEWEB_PLUGIN_SIGNATURE_PRIVATE_KEY }}" > ./keys/keeweb-plugin-sign.pem.key
pnpm build
rm ./keys/keeweb-plugin-sign.pem.key
# Deploy to publish branch
# REF https://github.com/marketplace/actions/github-pages
- name: Deploy to publish branch
if: success()
uses: crazy-max/ghaction-github-pages@v3
with:
## 构建产物目录 | directory of build artifacts
build_dir: ${{ env.PACKAGE_PATH }}/dist
## 提交到目标分支
target_branch: publish
env:
GITHUB_TOKEN: ${{ secrets.PAT_ACTIONS }}