name: Publish Mini Program Preview on: push: branches: - main paths: - "miniapp/**" - ".nvmrc" - ".gitea/workflows/miniapp-preview.yml" jobs: preview: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version-file: .nvmrc cache: npm cache-dependency-path: miniapp/package-lock.json - name: Install dependencies working-directory: miniapp run: npm ci - name: Run tests working-directory: miniapp run: npm test -- --runInBand - name: Configure production API working-directory: miniapp env: TARO_APP_API_URL: ${{ vars.MINIAPP_API_URL }} run: | test -n "$TARO_APP_API_URL" printf 'TARO_APP_API_URL=%s\n' "$TARO_APP_API_URL" > .env.production.local - name: Build WeChat Mini Program working-directory: miniapp run: npm run build:weapp - name: Materialize the upload key env: WECHAT_CI_PRIVATE_KEY: ${{ secrets.WECHAT_CI_PRIVATE_KEY }} run: | test -n "$WECHAT_CI_PRIVATE_KEY" umask 077 printf '%s' "$WECHAT_CI_PRIVATE_KEY" > "$RUNNER_TEMP/wechat-ci.key" - uses: https://gitea.neatcn.com/pets/deployment-toolkit/actions/wechat-preview@v1.0.2 with: project-path: miniapp appid: ${{ vars.MINIAPP_APPID }} robot: ${{ vars.MINIAPP_ROBOT }} private-key-path: ${{ runner.temp }}/wechat-ci.key qrcode-output: ${{ runner.temp }}/miniapp-preview.png version-label: ${{ gitea.sha }} - uses: actions/upload-artifact@v4 with: name: miniapp-preview-${{ gitea.sha }} path: ${{ runner.temp }}/miniapp-preview.png if-no-files-found: error - name: Remove temporary credentials if: always() run: rm -f "$RUNNER_TEMP/wechat-ci.key"