Skip to content

Commit 30cc03f

Browse files
chore(docs): action deploy tcb (#1695)
Co-authored-by: drl990114 <[email protected]>
1 parent e1df24d commit 30cc03f

File tree

3 files changed

+83
-7
lines changed

3 files changed

+83
-7
lines changed

.github/workflows/deploy-tcb.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Publish root to TCB
2+
on:
3+
check_suite:
4+
types: [completed]
5+
push:
6+
branches:
7+
- next
8+
schedule:
9+
- cron: "0 21 * * *"
10+
11+
env:
12+
CI: true
13+
jobs:
14+
publish:
15+
name: Publish
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v4
19+
with:
20+
ref: ${{ github.head_ref }}
21+
22+
- name: Cache pnpm modules and build
23+
uses: actions/cache@v3
24+
with:
25+
path: |
26+
node_modules
27+
key: ${{ runner.os }}-tcb
28+
restore-keys: |
29+
${{ runner.os }}-
30+
31+
- name: install
32+
uses: pnpm/action-setup@v2
33+
with:
34+
version: 7
35+
run_install: |
36+
- recursive: true
37+
args: [--frozen-lockfile, --strict-peer-dependencies]
38+
39+
- name: Build
40+
run: pnpm run build:doc
41+
42+
- name: Deploy static to Tencent CloudBase
43+
id: deployStatic
44+
uses: TencentCloudBase/[email protected]
45+
with:
46+
secretId: ${{ secrets.TCB_SECRET_ID }}
47+
secretKey: ${{ secrets.TCB_SECRET_KEY }}
48+
envId: ${{ secrets.TCB_TARO_DOCS_ENV_ID }}
49+
staticSrcPath: packages/taro-ui-docs/dist

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"preinstall": "npx only-allow pnpm",
1515
"build": "pnpm -r run build",
1616
"build:demo": "pnpm --filter=taro-ui-demo build:h5",
17+
"build:doc": "pnpm run build:demo && pnpm --filter=taro-ui-docs build",
1718
"clean": " rimraf **/dist && rimraf **/node_modules",
1819
"prepare": "husky install"
1920
},

packages/taro-ui-docs/build/build-static.js

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,38 @@ spinner.start()
99
// packages/taro-ui-docs/dist/h5
1010
fs.emptyDirSync(path.resolve(__dirname, '../dist/h5'))
1111

12-
fs.copy(
13-
// packages/taro-ui-demo/dist
14-
path.resolve(__dirname, '../../taro-ui-demo/dist'),
15-
path.resolve(__dirname, '../dist/h5')
16-
)
17-
.then(() => {
12+
function mergeDemoH5AndDist() {
13+
const demoH5Path = path.resolve(__dirname, '../../taro-ui-demo/dist')
14+
if (!fs.existsSync(demoH5Path)) {
15+
console.log('Please run `npm run build:demo` first')
1816
spinner.stop()
17+
return
18+
}
19+
20+
const distH5Path = path.resolve(__dirname, '../dist/h5')
21+
const distPath = path.resolve(__dirname, '../dist')
22+
const files = fs.readdirSync(demoH5Path)
23+
24+
const promises = []
25+
files.forEach(file => {
26+
if (file !== 'index.html') {
27+
promises.push(
28+
fs.copy(path.resolve(demoH5Path, file), path.resolve(distPath, file))
29+
)
30+
} else {
31+
promises.push(
32+
fs.copy(path.resolve(demoH5Path, file), path.resolve(distH5Path, file))
33+
)
34+
}
1935
})
20-
.catch(err => console.error(err))
36+
37+
Promise.all(promises)
38+
.then(() => {
39+
spinner.stop()
40+
})
41+
.catch(err => {
42+
console.log('build static error:', err)
43+
})
44+
}
45+
46+
mergeDemoH5AndDist()

0 commit comments

Comments
 (0)