From c1781bb8cbf80fee40676c53fb59bf5d8b5e2929 Mon Sep 17 00:00:00 2001 From: anhnhu Date: Tue, 14 May 2024 15:14:31 +0700 Subject: [PATCH] Update code build test --- .github/workflows/push-webapp-test-01.yml | 4 ++-- packages/webapp/webpack.config.cjs | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/.github/workflows/push-webapp-test-01.yml b/.github/workflows/push-webapp-test-01.yml index a63d522989c..e3e334d7bff 100644 --- a/.github/workflows/push-webapp-test-01.yml +++ b/.github/workflows/push-webapp-test-01.yml @@ -21,7 +21,7 @@ jobs: uses: actions/checkout@v3 with: fetch-depth: 0 - token: ${{ secrets.GH_PAT }} + token: ${{ secrets.GH_AUTOMATION_TOKEN }} - name: Setup Node uses: actions/setup-node@v3 with: @@ -40,7 +40,7 @@ jobs: if [ ${{ github.ref_name }} == 'telegram-wallet' ]; then yarn run webapp:change-build-number fi - yarn webapp:build --env GAME_API_HOST ${{ secrets.GAME_DEV_SERVER_1 }} + yarn webapp:build --env GAME_API_HOST ${{ secrets.GAME_DEV_SERVER_1 }} TELEGRAM_WEBAPP_LINK ${{ secrets.TELEGRAM_WEBAPP_LINK_01 }} - name: Publish to Cloudflare Pages id: cloudflare_deployment uses: cloudflare/pages-action@v1 diff --git a/packages/webapp/webpack.config.cjs b/packages/webapp/webpack.config.cjs index 8dab488ec55..774b642b68b 100644 --- a/packages/webapp/webpack.config.cjs +++ b/packages/webapp/webpack.config.cjs @@ -22,12 +22,21 @@ const HtmlWebpackPlugin = require('html-webpack-plugin'); const args = process.argv.slice(2); let mode = 'production'; +let apiGameHost = 'https://game-api.anhmtv.xyz'; +let telegramLink = ''; + if (args) { args.forEach((p, index) => { if (p === '--mode') { mode = args[index + 1] || mode; } + if (p === 'GAME_API_HOST') { + apiGameHost = args[index + 1] || apiGameHost; + } + if (p === 'TELEGRAM_WEBAPP_LINK') { + telegramLink = args[index + 1] || telegramLink; + } }); } @@ -61,6 +70,15 @@ const _additionalEnv = { TELEGRAM_WEBAPP_LINK: JSON.stringify(process.env.TELEGRAM_WEBAPP_LINK) }; +if (!_additionalEnv.GAME_API_HOST){ + _additionalEnv.GAME_API_HOST = JSON.stringify(apiGameHost); +} + +if (!_additionalEnv.TELEGRAM_WEBAPP_LINK){ + _additionalEnv.GAME_API_HOST = JSON.stringify(telegramLink); +} +console.log('GAME_API_HOST: ', apiGameHost); +console.log('TELEGRAM_WEBAPP_LINK: ', telegramLink); const createConfig = (entry, alias = {}, useSplitChunk = false) => { const result = { context: __dirname,