diff --git a/.github/workflows/deploy-legacy.yml b/.github/workflows/deploy-legacy.yml index c3b6a0925d5..1b1ae4bca2e 100644 --- a/.github/workflows/deploy-legacy.yml +++ b/.github/workflows/deploy-legacy.yml @@ -242,48 +242,47 @@ jobs: - name: Upload and Deploy run: | for i in {0..1}; do + TS_MACHINE_NAME=${TS_MACHINE_NAME_PREFIX}-${{ matrix.lang-name-short }}-${i} + CURRENT_DATE=$(date +%Y%m%d) + CLIENT_SRC=client-${{ matrix.lang-name-short }}.tar + CLIENT_DST=/tmp/client-${{ matrix.lang-name-short }}-${CURRENT_DATE}-${{ github.run_id }}.tar + CLIENT_BINARIES=${{needs.setup-jobs.outputs.tgt_env_short}}-release-$CURRENT_DATE-${{ github.run_id }} - TS_MACHINE_NAME=${TS_MACHINE_NAME_PREFIX}-${{ matrix.lang-name-short }}-${i} - CURRENT_DATE=$(date +%Y%m%d) - CLIENT_SRC=client-${{ matrix.lang-name-short }}.tar - CLIENT_DST=/tmp/client-${{ matrix.lang-name-short }}-${CURRENT_DATE}-${{ github.run_id }}.tar - CLIENT_BINARIES=${{needs.setup-jobs.outputs.tgt_env_short}}-release-$CURRENT_DATE-${{ github.run_id }} + # Upload client archive + scp $CLIENT_SRC $TS_USERNAME@$TS_MACHINE_NAME:$CLIENT_DST + if [ $? -ne 0 ]; then echo "::error::Failed to upload client archive"; exit 1; fi - # Upload client archive - scp $CLIENT_SRC $TS_USERNAME@$TS_MACHINE_NAME:$CLIENT_DST - if [ $? -ne 0 ]; then echo "::error::Failed to upload client archive"; exit 1; fi + ssh $TS_USERNAME@$TS_MACHINE_NAME /bin/bash << EOF + set -e - ssh $TS_USERNAME@$TS_MACHINE_NAME /bin/bash << EOF - set -e + # Extract client archive + mkdir -p /home/$TS_USERNAME/client/releases/$CLIENT_BINARIES && \ + tar -xzf $CLIENT_DST -C /home/$TS_USERNAME/client/releases/$CLIENT_BINARIES --strip-components=2 && \ + rm $CLIENT_DST && \ + du -sh /home/$TS_USERNAME/client/releases/$CLIENT_BINARIES - # Extract client archive - mkdir -p /home/$TS_USERNAME/client/releases/$CLIENT_BINARIES && \ - tar -xzf $CLIENT_DST -C /home/$TS_USERNAME/client/releases/$CLIENT_BINARIES --strip-components=2 && \ - rm $CLIENT_DST && \ - du -sh /home/$TS_USERNAME/client/releases/$CLIENT_BINARIES + cd /home/$TS_USERNAME/client - cd /home/$TS_USERNAME/client + # Environment setup + export NVM_DIR=\$HOME/.nvm && [ -s "\$NVM_DIR/nvm.sh" ] && source "\$NVM_DIR/nvm.sh" && \ + nvm ls | grep 'default' && \ + echo "Node.js version:" && node --version - # Environment setup - export NVM_DIR=\$HOME/.nvm && [ -s "\$NVM_DIR/nvm.sh" ] && source "\$NVM_DIR/nvm.sh" && \ - nvm ls | grep 'default' && \ - echo "Node.js version:" && node --version + npm install -g serve@13 - npm install -g serve@13 + # Primary client setup + rm -f client-start-primary.sh && \ + echo "serve -c ../../serve.json releases/$CLIENT_BINARIES -p 50505" >> client-start-primary.sh && \ + chmod +x client-start-primary.sh && \ + pm2 delete client-primary || true && \ + pm2 start ./client-start-primary.sh --name client-primary - # Primary client setup - rm -f client-start-primary.sh && \ - echo "serve -c ../../serve.json releases/$CLIENT_BINARIES -p 50505" >> client-start-primary.sh && \ - chmod +x client-start-primary.sh && \ - pm2 delete client-primary || true && \ - pm2 start ./client-start-primary.sh --name client-primary - - # Secondary client setup - rm -f client-start-secondary.sh && \ - echo "serve -c ../../serve.json releases/$CLIENT_BINARIES -p 52525" >> client-start-secondary.sh && \ - chmod +x client-start-secondary.sh && \ - pm2 delete client-secondary || true && \ - pm2 start ./client-start-secondary.sh --name client-secondary + # Secondary client setup + rm -f client-start-secondary.sh && \ + echo "serve -c ../../serve.json releases/$CLIENT_BINARIES -p 52525" >> client-start-secondary.sh && \ + chmod +x client-start-secondary.sh && \ + pm2 delete client-secondary || true && \ + pm2 start ./client-start-secondary.sh --name client-secondary EOF if [ $? -ne 0 ]; then echo "::error::Deployment to $TS_MACHINE_NAME failed"