Files
jdt-user/.gitea/workflows/ci.yaml
YuanHuakk b6b6649a9b
All checks were successful
CI Build & Upload (WeApp) / build-upload-dev (push) Has been skipped
CI Build & Upload (WeApp) / build-upload-prod (push) Successful in 4m55s
CI Build & Upload (WeApp) / build-upload-reserve (push) Successful in 2m34s
ci(other): ci脚本换源
2025-11-05 11:56:16 +08:00

127 lines
5.1 KiB
YAML

name: CI Build & Upload (WeApp)
on:
push:
branches:
- test
- master
jobs:
build-upload-dev:
if: ${{ gitea.ref == 'refs/heads/test' }}
runs-on: gitea_act_runner
container:
image: node:24-alpine
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install deps
run: |
npm install -g pnpm
pnpm config set registry https://registry.npmmirror.com/
pnpm install
- name: Build & Upload (test)
run: |
pnpm build:weapp:test:upload
rm -rf dist.tar || true
- name: Notify WeCom (Dev)
if: always()
env:
WEBHOOK_KEY: ${{ secrets.QYWX_WEBHOOK_KEY }}
STATUS: ${{ job.status }}
REPO: ${{ gitea.repository }}
RUN_URL: ${{ gitea.server_url }}/${{ gitea.repository }}/actions/runs/${{ gitea.run_id }}
BRANCH: ${{ gitea.ref_name }}
COMMIT: ${{ gitea.sha }}
ACTOR: ${{ gitea.actor }}
COMMIT_MSG: ${{ gitea.event.head_commit.message }}
run: |
apk add --no-cache curl jq
EMOJI=$( [ "$STATUS" = "success" ] && echo "✅ 构建成功" || echo "❌ 构建失败" )
MSG="$(printf "%s\n**项目**: %s (构建 #%s)\n**分支**: %s\n**提交**: %s\n**作者**: %s\n**信息**: %s\n**详情**: [查看构建详情](%s)" \
"$EMOJI" "$REPO" "${{ gitea.run_number }}" "$BRANCH" "$COMMIT" "$ACTOR" "$(echo "$COMMIT_MSG" | tr '\n' ' ' | tr -s ' ')" "$RUN_URL")"
JSON=$(jq -n --arg content "$MSG" '{msgtype:"markdown", markdown:{content:$content}}')
curl -sS -H 'Content-Type: application/json' -d "$JSON" "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=${WEBHOOK_KEY}"
build-upload-prod:
if: ${{ gitea.ref == 'refs/heads/master' }}
runs-on: gitea_act_runner
container:
image: node:24-alpine
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install deps
run: |
npm install -g pnpm
pnpm config set registry https://registry.npmmirror.com/
pnpm install
- name: Build & Upload (prod)
run: |
pnpm build:weapp:prod:upload
rm -rf dist.tar || true
- name: Notify WeCom (Prod)
if: always()
env:
WEBHOOK_KEY: ${{ secrets.QYWX_WEBHOOK_KEY }}
STATUS: ${{ job.status }}
REPO: ${{ gitea.repository }}
RUN_URL: ${{ gitea.server_url }}/${{ gitea.repository }}/actions/runs/${{ gitea.run_id }}
BRANCH: ${{ gitea.ref_name }}
COMMIT: ${{ gitea.sha }}
ACTOR: ${{ gitea.actor }}
COMMIT_MSG: ${{ gitea.event.head_commit.message }}
run: |
apk add --no-cache curl jq
EMOJI=$( [ "$STATUS" = "success" ] && echo "✅ 构建成功" || echo "❌ 构建失败" )
MSG="$(printf "%s\n**项目**: %s (构建 #%s)\n**分支**: %s\n**提交**: %s\n**作者**: %s\n**信息**: %s\n**详情**: [查看构建详情](%s)" \
"$EMOJI" "$REPO" "${{ gitea.run_number }}" "$BRANCH" "$COMMIT" "$ACTOR" "$(echo "$COMMIT_MSG" | tr '\n' ' ' | tr -s ' ')" "$RUN_URL")"
JSON=$(jq -n --arg content "$MSG" '{msgtype:"markdown", markdown:{content:$content}}')
curl -sS -H 'Content-Type: application/json' -d "$JSON" "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=${WEBHOOK_KEY}"
build-upload-reserve:
if: ${{ gitea.ref == 'refs/heads/master' }}
runs-on: gitea_act_runner
container:
image: node:24-alpine
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install deps
run: |
npm install -g pnpm
pnpm config set registry https://registry.npmmirror.com/
pnpm install
- name: Build & Upload (reserve)
run: |
pnpm build:weapp:reserve:upload
rm -rf dist.tar || true
- name: Notify WeCom (Reserve)
if: always()
env:
WEBHOOK_KEY: ${{ secrets.QYWX_WEBHOOK_KEY }}
STATUS: ${{ job.status }}
REPO: ${{ gitea.repository }}
RUN_URL: ${{ gitea.server_url }}/${{ gitea.repository }}/actions/runs/${{ gitea.run_id }}
BRANCH: ${{ gitea.ref_name }}
COMMIT: ${{ gitea.sha }}
ACTOR: ${{ gitea.actor }}
COMMIT_MSG: ${{ gitea.event.head_commit.message }}
run: |
sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories || true
apk add --no-cache curl jq
EMOJI=$( [ "$STATUS" = "success" ] && echo "✅ 构建成功" || echo "❌ 构建失败" )
MSG="$(printf "%s\n**项目**: %s (构建 #%s)\n**分支**: %s\n**提交**: %s\n**作者**: %s\n**信息**: %s\n**详情**: [查看构建详情](%s)" \
"$EMOJI" "$REPO" "${{ gitea.run_number }}" "$BRANCH" "$COMMIT" "$ACTOR" "$(echo "$COMMIT_MSG" | tr '\n' ' ' | tr -s ' ')" "$RUN_URL")"
JSON=$(jq -n --arg content "$MSG" '{msgtype:"markdown", markdown:{content:$content}}')
curl -sS -H 'Content-Type: application/json' -d "$JSON" "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=${WEBHOOK_KEY}"