Upload a built WeChat Mini Program from GitHub Actions with WeChat's official miniprogram-ci SDK.
The official SDK version and integrity are pinned in this repository's lockfile. The action installs that locked runtime before uploading, so consumers only need a built Mini Program directory, an AppID, and a code upload private key.
jobs:
upload:
runs-on: ubuntu-latest
environment: wechat-upload
steps:
- uses: actions/checkout@v7
- name: Build Mini Program
run: npm ci && npm run build:wechat
- name: Upload development version
uses: YGM-Studio/wechat-miniprogram-upload-action@v1
with:
appid: ${{ vars.WECHAT_APPID }}
private-key: ${{ secrets.WECHAT_PRIVATE_KEY }}
project-path: dist/wxThe version defaults to the version field in the consumer repository's package.json. The upload creates a development version; it does not submit the Mini Program for review or publish it.
| Input | Required | Default | Description |
|---|---|---|---|
appid |
Yes | WeChat Mini Program AppID | |
private-key |
Yes | Full PEM content of the code upload private key | |
project-path |
No | dist/wx |
Directory containing project.config.json |
version |
No | package.json version |
Version to upload |
description |
No | GitHub run and commit | Version description |
robot |
No | 1 |
CI robot number from 1 to 30 |
setting |
No | {} |
JSON upload settings passed to miniprogram-ci |
| Output | Description |
|---|---|
version |
Uploaded version |
description |
Uploaded version description |
project-path |
Absolute uploaded project path |
- Open the WeChat Mini Program admin console.
- Go to Development Management -> Development Settings -> Mini Program Code Upload.
- Generate and download a code upload private key.
- Store its complete PEM content as
WECHAT_PRIVATE_KEYin GitHub Actions Secrets. - Store the Mini Program AppID as
WECHAT_APPIDin GitHub Actions Variables.
GitHub-hosted runners do not have a fixed outbound IP. If WeChat's upload IP allowlist is enabled, use a runner with a fixed outbound IP or manage the allowlist separately.
The private key is written to a mode 0600 temporary file for the upload and is always removed afterward.
这是一个使用微信官方 miniprogram-ci 上传小程序开发版本的 GitHub Action。上传密钥请保存到 GitHub Secret,不要提交进仓库。project-path 必须指向包含 project.config.json 的构建目录。