Skip to content

Commit 79b55b7

Browse files
author
v_guanglwen
committed
feat: 修改miniprogram-ci
1 parent 55a74a1 commit 79b55b7

File tree

3 files changed

+49
-14
lines changed

3 files changed

+49
-14
lines changed

.github/workflows/ci.yml

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,34 @@ jobs:
1111
upload:
1212
runs-on: ubuntu-latest
1313
steps:
14+
- uses: actions/checkout@v4
15+
with:
16+
fetch-depth: 0
17+
submodules: 'recursive'
18+
token: ${{ secrets.GITHUB_TOKEN }}
19+
20+
- name: Verify file existence
21+
run: |
22+
echo "当前工作目录:"
23+
pwd
24+
echo "目录内容:"
25+
ls -la
26+
echo "build目录内容:"
27+
ls -la ./build/
28+
echo "子模块状态:"
29+
git submodule status
30+
31+
- name: Install dependencies
32+
run: npm install
33+
34+
- name: Run package script
35+
run: npm run init
36+
1437
- name: Upload MiniProgram
1538
env:
1639
WX_PRIVATE_KEY: ${{ secrets.WX_PRIVATE_KEY }}
1740
run: |
41+
mkdir -p ./build
1842
echo "$WX_PRIVATE_KEY" > ./build/key
19-
node ./build/ci.js
43+
chmod +x ./build/ci.js
44+
node ./build/ci.js --skip-key-write

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[submodule "miniprogram/packageSkylineExamples"]
22
path = miniprogram/packageSkylineExamples
3-
url = git@github.com:wechat-miniprogram/awesome-skyline.git
3+
url = https://github.com/wechat-miniprogram/awesome-skyline.git

build/ci.js

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,24 @@
1-
const path = require('path')
2-
const ci = require('miniprogram-ci')
3-
const fs = require('fs')
4-
const packageJson = require('../package.json')
1+
import path from 'path'
2+
import { fileURLToPath } from 'url'
3+
import fs from 'fs'
4+
import ci from 'miniprogram-ci'
5+
import packageJson from '../package.json' with { type: 'json' }
6+
const __filename = fileURLToPath(import.meta.url)
7+
const __dirname = path.dirname(__filename)
8+
const privateKeyPath = path.resolve(__dirname, './key')
59

6-
const privateKeyContent = process.env.WX_PRIVATE_KEY
7-
if (!privateKeyContent) {
8-
throw new Error('未找到私钥内容,请确保已正确配置 GitHub Secrets')
10+
// 检查私钥文件是否已存在
11+
if (!fs.existsSync(privateKeyPath)) {
12+
const privateKeyContent = process.env.WX_PRIVATE_KEY
13+
if (!privateKeyContent) {
14+
throw new Error('未找到私钥内容,请确保已正确配置 GitHub Secrets')
15+
}
16+
console.log('>>>>写入私钥文件:', privateKeyPath);
17+
fs.writeFileSync(privateKeyPath, privateKeyContent)
918
}
1019

11-
const privateKeyPath = path.resolve(__dirname, './private.key')
12-
fs.writeFileSync(privateKeyPath, privateKeyContent)
13-
1420
const project = new ci.Project({
15-
appid: 'wxe5f52902cf4de896',
21+
appid: 'wx622bee4f78fa4f5a',
1622
type: 'miniProgram',
1723
projectPath: path.resolve(__dirname, '../'),
1824
privateKeyPath: path.resolve(__dirname, './key'),
@@ -30,9 +36,11 @@ const params = {
3036
minifyWXML: true,
3137
minifyWXSS: true,
3238
codeProtect: false,
33-
autoPrefixWXSS: true
39+
autoPrefixWXSS: true,
40+
ignoreUploadUnusedFiles: true
3441
},
3542
}
43+
await ci.packNpm(project, {})
3644
ci.upload({
3745
project,
3846
...params
@@ -45,3 +53,5 @@ ci.upload({
4553
// 删除临时私钥文件
4654
fs.unlinkSync(privateKeyPath)
4755
})
56+
57+

0 commit comments

Comments
 (0)