Skip to content
Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

WeChat MiniProgram GitHub Action

中文使用文档 利用 GitHub Actions 实现小程序的持续集成

A GitHub Action to automate deploying WeChat MiniProgram by using miniprogram-ci.

It will enable workflows to easily preview and upload your MiniProgram to the WeChat.

The implementation of preview or upload is the same as VSCode extension miniprogram-vscode-extension.

Usage

Here's an example workflow which publishes an extension when you push to the master branch.

Preview

name: Preview MiniProgramon:
push:
branches:
- masterjobs:
preview:
runs-on: ubuntu-lateststeps:
- name: Checkoutuses: actions/checkout@v3
- id: previewname: Compileuses: crazyurus/miniprogram-action@2.0.0with:
action_type: previewenv:
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
- name: QR Codeuses: peter-evans/commit-comment@v2with:
body: | Copy the following content to the address bar of the browser to open the preview QR code ``` ${{ steps.preview.outputs.preview_qrcode }} ```

Upload

name: Upload MiniProgramon:
push:
tags:
- "*.*.*"jobs:
upload:
runs-on: ubuntu-lateststeps:
- name: Checkoutuses: actions/checkout@v3
- name: Uploaduses: crazyurus/miniprogram-action@2.0.0with:
action_type: uploadversion: ${{ github.ref_name }}env:
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}

Parameters

Input

NameRequiredDescriptionDefault Value
action_typefalseAction type, preview or uploadupload
project_pathfalseProject path, which contains project.config.json.
page_pathfalsePage path, one of the pages in app.json
page_queryfalsePage query
scenefalseScene code1011
versionfalsePublish version1.0.0
descriptionfalseRelease notes
cifalseNumber of CI24

Output

NameAlwaysDescriptionDefault Value
preview_qrcodefalseThe base64 content of the MiniProgram to preview the QR code
preview_qrcode_pathfalseThe file path of the MiniProgram to preview the QR code

Secrets

The PRIVATE_KEY secret is used to authenticate with WeChat when running the miniprogram-ci CLI. You can find out how to create this token here on the WeChat Developers: CI

There are mainly the following primary steps:

  1. Login to https://mp.weixin.qq.com
  2. Find "开发" - "开发设置" - "小程序代码上传"
  3. Generate private key and download key file, and close IP whitelist
  4. Copy the contents of the key file and add in GitHub repository settings. Find "Settings" - "Secrets" - "Actions", and click "New repository secret" button. Enter the "Name" as PRIVATE_KEY, and "Secret" as the contents of the key file

Example Use Cases

  • Preview MiniProgram if the master branch has changed since the last build.
  • Upload MiniProgram when the tag is created on GitHub.

Here is a example project recruit-miniprogram

About

A GitHub Action to automate deploying WeChat MiniProgram

Topics

Resources

Stars

20 stars

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages