Code Monkey home page Code Monkey logo

miniprogram-action's Introduction

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 MiniProgram
on:
  push:
    branches:
      - master
jobs:
  preview:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v3
      - id: preview
        name: Compile
        uses: crazyurus/[email protected]
        with:
          action_type: preview
        env:
          PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
      - name: QR Code
        uses: peter-evans/commit-comment@v2
        with:
          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 MiniProgram
on:
  push:
    tags:
      - "*.*.*"
jobs:
  upload:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v3
      - name: Upload
        uses: crazyurus/[email protected]
        with:
          action_type: upload
          version: ${{ github.ref_name }}
        env:
          PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}

Parameters

Input

Name Required Description Default Value
action_type false Action type, preview or upload upload
project_path false Project path, which contains project.config.json .
page_path false Page path, one of the pages in app.json
page_query false Page query
scene false Scene code 1011
version false Publish version 1.0.0
description false Release notes

Output

Name Always Description Default Value
preview_qrcode false The base64 content of the MiniProgram to preview the QR code
preview_qrcode_path false The 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

miniprogram-action's People

Contributors

crazyurus avatar jjerryyz avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.