diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 49f1f81b..dada1837 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,9 +11,34 @@ jobs: upload: runs-on: ubuntu-latest steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + submodules: 'recursive' + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Verify file existence + run: | + echo "当前工作目录:" + pwd + echo "目录内容:" + ls -la + echo "build目录内容:" + ls -la ./build/ + echo "子模块状态:" + git submodule status + + - name: Install dependencies + run: npm install + + - name: Run package script + run: npm run init + - name: Upload MiniProgram env: WX_PRIVATE_KEY: ${{ secrets.WX_PRIVATE_KEY }} run: | + mkdir -p ./build echo "$WX_PRIVATE_KEY" > ./build/key - node ./build/ci.js + chmod +x ./build/ci.js + node ./build/ci.js --skip-key-write diff --git a/.gitmodules b/.gitmodules index 2f398a69..6ccb8b5f 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "miniprogram/packageSkylineExamples"] path = miniprogram/packageSkylineExamples - url = git@github.com:wechat-miniprogram/awesome-skyline.git + url = https://github.com/wechat-miniprogram/awesome-skyline.git diff --git a/build/ci.js b/build/ci.js index 9b78edc9..bc3f9d7a 100644 --- a/build/ci.js +++ b/build/ci.js @@ -1,18 +1,24 @@ -const path = require('path') -const ci = require('miniprogram-ci') -const fs = require('fs') -const packageJson = require('../package.json') +import path from 'path' +import { fileURLToPath } from 'url' +import fs from 'fs' +import ci from 'miniprogram-ci' +import packageJson from '../package.json' with { type: 'json' } +const __filename = fileURLToPath(import.meta.url) +const __dirname = path.dirname(__filename) +const privateKeyPath = path.resolve(__dirname, './key') -const privateKeyContent = process.env.WX_PRIVATE_KEY -if (!privateKeyContent) { - throw new Error('未找到私钥内容,请确保已正确配置 GitHub Secrets') +// 检查私钥文件是否已存在 +if (!fs.existsSync(privateKeyPath)) { + const privateKeyContent = process.env.WX_PRIVATE_KEY + if (!privateKeyContent) { + throw new Error('未找到私钥内容,请确保已正确配置 GitHub Secrets') + } + console.log('>>>>写入私钥文件:', privateKeyPath); + fs.writeFileSync(privateKeyPath, privateKeyContent) } -const privateKeyPath = path.resolve(__dirname, './private.key') -fs.writeFileSync(privateKeyPath, privateKeyContent) - const project = new ci.Project({ - appid: 'wxe5f52902cf4de896', + appid: 'wx622bee4f78fa4f5a', type: 'miniProgram', projectPath: path.resolve(__dirname, '../'), privateKeyPath: path.resolve(__dirname, './key'), @@ -30,9 +36,11 @@ const params = { minifyWXML: true, minifyWXSS: true, codeProtect: false, - autoPrefixWXSS: true + autoPrefixWXSS: true, + ignoreUploadUnusedFiles: true }, } +await ci.packNpm(project, {}) ci.upload({ project, ...params @@ -45,3 +53,5 @@ ci.upload({ // 删除临时私钥文件 fs.unlinkSync(privateKeyPath) }) + +