diff --git a/client/mobile/scripts/notify-links.js b/client/mobile/scripts/notify-links.js index 04e167f2..bf2fd5b3 100644 --- a/client/mobile/scripts/notify-links.js +++ b/client/mobile/scripts/notify-links.js @@ -6,6 +6,7 @@ const path = require('path'); // reference: https://docs.codemagic.io/yaml-basic-configuration/environment-variables/#artifact-links const artifactLinks = process.env['CM_ARTIFACT_LINKS']; const tailchatSubscribeId = process.env['TAILCHAT_SUBSCRIBE_ID']; +const branch = process.env['CM_BRANCH']; console.log('artifactLinks:', artifactLinks); @@ -18,10 +19,15 @@ if (tailchatSubscribeId) { links .map((link) => { const { name, url, md5, versionName } = link; + const pagesUrl = + branch === 'master' + ? 'https://tailchat.pages.dev/app-release.apk' + : `https://${branch}.tailchat.pages.dev/app-release.apk`; + return ( `${name}\n` + `version: ${versionName}(${md5})\n` + - `[url=${url}]Download[/url]` + `[url=${pagesUrl}]Download from Pages[/url] or [url=${url}]Download from CI[/url]` ); }) .join('\n=========\n'); diff --git a/codemagic.yaml b/codemagic.yaml index a4f96cfa..848c50cf 100644 --- a/codemagic.yaml +++ b/codemagic.yaml @@ -46,14 +46,22 @@ workflows: recipients: - moonrailgun@gmail.com scripts: - - name: Notify artifact URL to Tailchat - script: | - node scripts/notify-links.js - name: Install wrangler script: npm install -g wrangler - name: Deploy to Cloudflare Pages script: | - wrangler pages publish android/app/build/outputs/apk/release --project-name tailchat --branch $CM_BRANCH + if [[ -f ~/SUCCESS ]]; then + if [[ $CM_BRANCH == "master" ]]; then + # deploy to production + wrangler pages publish android/app/build/outputs/apk/release --project-name tailchat --branch main + else + wrangler pages publish android/app/build/outputs/apk/release --project-name tailchat --branch $CM_BRANCH + fi + fi + - name: Notify artifact URL to Tailchat + script: | + node scripts/notify-links.js + ios: name: build, test & publish iOS version