File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11# project_workflows
22
3- 托管了很多开箱即用的ci配置,用于github action,为[ project_tool] ( https://github.com/seho-code-life/project_tool ) 提供安装支持,你可以使用这个工具,来可视化的添加ci配置文件并且轻松的管理workflows版本
3+ 托管了很多开箱即用的 ci 配置,用于 github action,为[ project_tool] ( https://github.com/seho-code-life/project_tool ) 提供安装支持,你可以使用这个工具,来可视化的添加 ci 配置文件并且轻松的管理 workflows 版本
44
5+ #### 你可能需要准备的仓库环境变量
6+
7+ | 键名 | 用途 |
8+ | ------------------------- | ------------------------------------------------------------------------- |
9+ | NPM_AUTH_TOKEN | NPM 包管理 自动发布需要配置的环境变量 [ 查看] ( src/npm-publish.yml ) |
10+ | QQ_UPLOAD_TOKEN | QQ 小程序自动发布版本需要配置的环境变量 [ 查看] ( src/build-mp-qq.yml ) |
11+ | WEIXIN_UPLOAD_PRIVATE_KEY | 微信 小程序自动发布版本需要配置的环境变量 [ 查看] ( src/build-mp-weixin.yml ) |
12+ | OSS_ACCESS_KEY_ID | OSS 自动发布版本需要的 oss id [ 查看] ( src/release-oss.yaml ) |
13+ | OSS_ACCESS_KEY_SECRET | OSS 自动发布版本需要的 oss secret [ 查看] ( src/release-oss.yaml ) |
14+ | GITEE_PRIVATE_KEY | 同步仓库信息到 gitee 需要的 private key [ 查看] ( src/sync2gitee.yml ) |
15+ | GITEE_TOKEN | 同步仓库信息到 gitee 需要的 token [ 查看] ( src/sync2gitee.yml ) |
16+
17+ 你需要仔细阅读每一个 yml 的配置,因为这可能与你的程序冲突,在 yml 文件中提供了很多注释说明和参考资料,这可能会帮助你完善 CI
18+
19+ #### 如何设置仓库环境变量?
20+
21+ github 仓库 -> setting -> secrets -> New repository secret
Original file line number Diff line number Diff line change 1+ # 自动编译&发布qq小程序版本
2+ # 参考1. https://segmentfault.com/a/1190000039125224
3+ # 由 https://github.com/seho-code-life/project_workflows 提供支持
4+ name : MP-QQ CI
5+
6+ on :
7+ push :
8+ branches :
9+ - master
10+ pull_request :
11+ branches :
12+ - master
13+
14+ jobs :
15+ build-qq-ci :
16+ runs-on : ubuntu-latest
17+
18+ steps :
19+ - name : Checkout
20+ uses : actions/checkout@master
21+
22+ - name : Node ENV
23+ uses : actions/setup-node@master
24+ with :
25+ node-version : 12.13.0
26+
27+ - name : Install Dependencies
28+ run : npm install
29+
30+ - name : PreBuild
31+ run : npm run build:mp-qq
32+
33+ - name : Version
34+ id : version
35+ uses : ashley-taylor/read-json-property-action@v1.0
36+ with :
37+ path : ./package.json
38+ property : version
39+
40+ # 这里的env配置需要阅读官方文档,要根据自己项目更改
41+ - name : Build
42+ uses : docker://qqminiapp/build:latest
43+ env :
44+ PLUGIN_VERSION : ${{steps.version.outputs.value}}
45+ PLUGIN_DESC : CI自动构建上传
46+ PLUGIN_APPTOKEN : ${{ secrets.QQ_UPLOAD_TOKEN }}
47+ PLUGIN_BUILDUSER : ${{ github.actor }}
48+ PLUGIN_EXPERIENCE : true
49+ PLUGIN_SOURCECODEPATH : ./dist/build/mp-qq
Original file line number Diff line number Diff line change 1+ # 自动编译&发布微信小程序版本
2+ # 参考1. https://segmentfault.com/a/1190000039125224
3+ # 由 https://github.com/seho-code-life/project_workflows 提供支持
4+
5+ name : MP-WEIXIN CI
6+
7+ on :
8+ push :
9+ branches :
10+ - master
11+ pull_request :
12+ branches :
13+ - master
14+
15+ jobs :
16+ build-weixin-ci :
17+ runs-on : ubuntu-latest
18+
19+ steps :
20+ - name : Checkout
21+ uses : actions/checkout@master
22+
23+ - name : Node ENV
24+ uses : actions/setup-node@master
25+ with :
26+ node-version : 12.13.0
27+
28+ - name : Install Dependencies
29+ run : npm i
30+
31+ - name : Build
32+ run : npm run build:mp-weixin
33+
34+ # see Project/Settings/Secrets
35+ - name : Generate private key for upload
36+ run : echo "$UPLOAD_PRIVATE_KEY" > private.key
37+ env :
38+ UPLOAD_PRIVATE_KEY : ${{ secrets.WEIXIN_UPLOAD_PRIVATE_KEY }}
39+
40+ # 以下设置,请根据自己项目需要进行调整
41+ # 需要根目录有package.json
42+ - name : Set PackageJson
43+ run : cp ./package.json ./dist/build/mp-weixin/package.json
44+
45+ # 上传代码,需要设置private.key具体位置
46+ - name : Upload to WeChat
47+ run : npx mp-ci upload ./dist/build/mp-weixin --pkp=./private.key
Original file line number Diff line number Diff line change 1+ # 为库提供npm发布支持且自动编译以及同步CNPM仓库
2+ # 注意事项: cnpm-sync这个任务需要你更改
3+ # 由 https://github.com/seho-code-life/project_workflows 提供支持
4+
5+ name : npm-publish
6+ on :
7+ push :
8+ branches :
9+ - master # Change this to your default branch
10+ jobs :
11+ npm-publish :
12+ name : npm-publish
13+ runs-on : ubuntu-latest
14+ steps :
15+ - name : checkout
16+ uses : actions/checkout@master
17+ - name : setup-node
18+ uses : actions/setup-node@master
19+ with :
20+ node-version : 12.13.0
21+ - name : install-build
22+ run : npm i && npm run build
23+ - name : publish-npm
24+ uses : JS-DevTools/npm-publish@v1
25+ with :
26+ token : ${{ secrets.NPM_AUTH_TOKEN }}
27+ cnpm-sync :
28+ name : cnpm-sync
29+ needs : npm-publish
30+ runs-on : ubuntu-latest
31+ steps :
32+ - name : sync-cnpm
33+ with :
34+ # 需要把‘express’换成你的包名,谨记
35+ url : " https://npmmirror.com/sync/express"
36+ timeout : 50000
37+ method : GET
Original file line number Diff line number Diff line change 1+ # 自动发布版本,上传oss
2+ # 由 https://github.com/seho-code-life/project_workflows 提供支持
3+ name : release-oss
4+ on :
5+ push :
6+ branches :
7+ - main
8+ jobs :
9+ main :
10+ name : main
11+ runs-on : ubuntu-latest
12+ steps :
13+ - name : 切换仓库
14+ uses : actions/checkout@master
15+ - name : 准备Node环境
16+ uses : actions/setup-node@master
17+ with :
18+ node-version : 12.13.0
19+ - name : 安装依赖以及编译
20+ run : npm i && CI= npm run build
21+ - name : 上传到OSS
22+ uses : fangbinwei/aliyun-oss-website-action@v1
23+ with :
24+ # 需要设置bucket
25+ accessKeyId : ${{ secrets.OSS_ACCESS_KEY_ID }}
26+ accessKeySecret : ${{ secrets.OSS_ACCESS_KEY_SECRET }}
27+ bucket : " "
28+ endpoint : " oss-cn-beijing.aliyuncs.com"
29+ folder : " build"
Original file line number Diff line number Diff line change 1+ # 同步github仓库信息到gitee
2+ # 由 https://github.com/seho-code-life/project_workflows 提供支持
3+ name : sync2gitee
4+
5+ on :
6+ schedule :
7+ # 设置触发时间,cron表达式
8+ - cron : " 30 17 * * *"
9+
10+ jobs :
11+ run :
12+ name : Sync GitHub to Gitee
13+ runs-on : ubuntu-latest
14+ steps :
15+ - name : Get current repository name
16+ id : info
17+ uses : actions/github-script@v3.1
18+ with :
19+ github-token : ${{secrets.GITHUB_TOKEN}}
20+ result-encoding : string
21+ script : |
22+ return context.repo.repo;
23+ - name : Mirror the GitHub repos to Gitee
24+ # 需要去这个action查询具体配置
25+ uses : Yikun/hub-mirror-action@master
26+ with :
27+ # github仓库地址
28+ src : github/swordCodePractice
29+ # gitee仓库地址
30+ dst : gitee/sword-code-practice
31+ # 需要设置key等变量,具体配置可以在Yikun/hub-mirror-action这个action中浏览文档
32+ dst_key : ${{ secrets.GITEE_PRIVATE_KEY }}
33+ dst_token : ${{ secrets.GITEE_TOKEN }}
34+ static_list : " ${{ steps.info.outputs.result }}"
35+ account_type : org
36+ force_update : true
You can’t perform that action at this time.
0 commit comments