From cc07d615f3cbac50fc73dbfd810cfccb34666607 Mon Sep 17 00:00:00 2001 From: haorwen Date: Wed, 17 Dec 2025 23:57:35 +0800 Subject: [PATCH] ci: add GitHub Actions workflows for release and CNB synchronization --- .github/workflows/release.yml | 51 ++++++++++++++++++++++++++++++++++ .github/workflows/sync-cnb.yml | 21 ++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/sync-cnb.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..4bb7422d --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,51 @@ +name: Release Build + +on: + push: + tags: + - 'v*' + +jobs: + build-and-release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Check if tag is on main branch + run: | + git fetch origin main + if ! git merge-base --is-ancestor ${{ github.sha }} origin/main; then + echo "Tag is not on main branch" + exit 1 + fi + + - uses: pnpm/action-setup@v2 + with: + version: 8 + + - uses: actions/setup-node@v4 + with: + node-version: '20' + cache: 'pnpm' + + - run: pnpm install + + - run: pnpm build:release + + - name: Package files + run: | + cd build + zip -r ../web.vocechat.zip . -x robots.txt CNAME email.tpl.html widget_demo.html + cd .. + + - name: Create Release + uses: softprops/action-gh-release@v1 + with: + files: | + web.vocechat.zip + build/web.vocechat.md5 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + diff --git a/.github/workflows/sync-cnb.yml b/.github/workflows/sync-cnb.yml new file mode 100644 index 00000000..d029fe2e --- /dev/null +++ b/.github/workflows/sync-cnb.yml @@ -0,0 +1,21 @@ +# .github/workflows/sync-cnb.yml + +name: Sync to CNB +on: [push] + +jobs: + sync: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Sync to CNB Repository + uses: docker://tencentcom/git-sync + env: + PLUGIN_TARGET_URL: "https://cnb.cool/haorwen/Privoce/vocechat-web.git" + PLUGIN_AUTH_TYPE: "https" + PLUGIN_USERNAME: "cnb" + PLUGIN_PASSWORD: ${{ secrets.CNB_TOKEN }} + PLUGIN_FORCE: "true" \ No newline at end of file