Operations 9 min read

Automated Deployment Solution for HaoDF WeChat Mini Programs

This article describes how HaoDF built an automated, visual CI/CD pipeline for its WeChat mini programs, replacing manual testing and release steps with a platform that handles environment configuration, QR‑code generation, code merging, and deployment while improving efficiency, reducing errors, and supporting future scaling.

HaoDF Tech Team
HaoDF Tech Team
HaoDF Tech Team
Automated Deployment Solution for HaoDF WeChat Mini Programs

Leveraging the massive user base of WeChat, HaoDF operates dozens of lightweight mini programs and needed a reliable, fast, and quality‑assured process for development, testing, and release.

Initially, the workflow relied on manual steps: developers packaged code, testers opened the developer tools, configured parameters, and spent about ten minutes per test, leading to low efficiency, frequent human errors, and a complex process.

The new automated deployment solution introduces a visual operations platform where developers and testers can trigger the entire pipeline with a few clicks, achieving higher efficiency, lower learning cost, and consistent results.

Key features include:

Visual Operations: Users interact with a web UI to start deployments, eliminating manual tool usage.

Automated Configuration: The platform automatically adjusts environment variables, updates the app ID and version, and merges code to the master branch after publishing.

One‑Click QR Code Generation: Before testing, the system checks if the master branch is merged, generates a QR code, and allows testers to scan and test within roughly two minutes.

Usage is divided into two main release modes:

Test Version: Testers configure the test domain via the platform, generate a QR code, and can also set up push entry points or public‑account menu redirects.

Experience Version: After offline verification, the platform uploads the mini‑program package to the WeChat public platform, automatically adjusts online parameters, and merges the code, removing manual steps.

The technical implementation runs four Mac Mini machines as build agents, each exposing a Node.js service that controls the WeChat Developer Tool in command‑line mode. Sample scripts modify environment variables, app IDs, and version numbers using sed, generate preview QR codes, and upload packages:

// Change ENV to TEST
let cmdENV = `sed -i "" s#"const ENV = [^;]*"#"const ENV = '${args.ENV}'"# config.js`;
// Change mini‑program appid
let testAppid = args.minipAppid || wxMinipPrdParams.appid;
cmdResult += `sed -i "" s#'"appid[^,]*"'#'"appid": "${testAppid}"'# project.config.json && `;
// Change version
cmdResult += `sed -i "" s#"const APP_VER[^;]*"#"const APP_VER = '${args.VER}'"# config.js && `;
let sourcePath = `${CODE_PATH}${wxMinip}/${opsCode}`;
let preview = await cmd(`sh ${CLI_PATH} -p ${sourcePath} ${qroutCmd} ${condition}`);

Additional scripts handle production uploads, automatic login recovery when the developer tool logs out, and DNS‑masq configuration to avoid servicewechat.com timeout issues. The login recovery notifies the responsible engineer via Enterprise WeChat and switches to another build machine if needed.

Future plans aim to speed up builds by caching compilation results, automatically select the optimal build machine, and eventually adopt the new miniprogram-ci tool for preview and upload.

In conclusion, the solution provides a practical, customizable CI/CD workflow for mini‑programs that has been running for nearly a year at HaoDF, continuously iterating to achieve reliable, error‑free releases.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

ci/cdOperationsDevOpsWeChat Mini Program
HaoDF Tech Team
Written by

HaoDF Tech Team

HaoDF Online tech practice and sharing—join us to discuss and help create quality healthcare through technology.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.