preparing upload_bundle.sh for reuse with different credentials

This commit is contained in:
rusefillc 2024-03-29 23:49:47 -04:00 committed by rusefillc
parent 6cf5938e39
commit f0a21e1b58
3 changed files with 11 additions and 7 deletions

View File

@ -264,7 +264,7 @@ jobs:
working-directory: ./artifacts
run: |
source ../firmware/config/boards/common_script_read_meta_env.inc ../firmware/${{ env.BOARD_META_PATH }}
bash ../firmware/bin/upload_bundle.sh
bash ../firmware/bin/upload_bundle.sh ${{ secrets.RUSEFI_SSH_USER }} ${{ secrets.RUSEFI_SSH_PASS }} ${{ secrets.RUSEFI_SSH_SERVER }}
- name: Add Bundles to Release
if: ${{ env.full == 'true' && env.upload == 'release' }}

View File

@ -207,7 +207,7 @@ runs:
if: ${{ contains(inputs.uploads, 'bundles') }}
working-directory: ${{inputs.rusefi_dir}}/artifacts
shell: bash
run: bash ../firmware/bin/upload_bundle.sh
run: bash ../firmware/bin/upload_bundle.sh ${{ secrets.RUSEFI_SSH_USER }} ${{ secrets.RUSEFI_SSH_PASS }} ${{ secrets.RUSEFI_SSH_SERVER }}
- name: Run Simulator
if: ${{ inputs.run_simulator == 'true' }}

View File

@ -1,22 +1,26 @@
#!/usr/bin/env bash
USER=$1
PASS=$2
HOST=$3
SCRIPT_NAME=$(basename "$0")
# technical debt: more than one file uses magic 'rusefi_bundle_' constant, can we extract constant?
FULL_BUNDLE_FILE="rusefi_bundle_${BUNDLE_NAME}.zip"
UPDATE_BUNDLE_FILE="rusefi_bundle_${BUNDLE_NAME}_autoupdate.zip"
if [ -n "$RUSEFI_SSH_USER" -a -n "$RUSEFI_SSH_PASS" -a -n "$RUSEFI_SSH_SERVER" ]; then
if [ -n "${USER}" -a -n "$PASS" -a -n "${HOST}" ]; then
echo "$SCRIPT_NAME: Uploading full bundle"
RET=0
if [ "$LTS" == "true" -a -n "$REF" ]; then
tar -czf - $FULL_BUNDLE_FILE | sshpass -p $RUSEFI_SSH_PASS ssh -o StrictHostKeyChecking=no $RUSEFI_SSH_USER@$RUSEFI_SSH_SERVER "mkdir -p build_server/lts/${REF}; tar -xzf - -C build_server/lts/${REF}"
tar -czf - $FULL_BUNDLE_FILE | sshpass -p $PASS ssh -o StrictHostKeyChecking=no ${USER}@${HOST} "mkdir -p build_server/lts/${REF}; tar -xzf - -C build_server/lts/${REF}"
RET=$((RET+$?+PIPESTATUS))
tar -czf - $UPDATE_BUNDLE_FILE | sshpass -p $RUSEFI_SSH_PASS ssh -o StrictHostKeyChecking=no $RUSEFI_SSH_USER@$RUSEFI_SSH_SERVER "mkdir -p build_server/lts/${REF}/autoupdate; tar -xzf - -C build_server/lts/${REF}/autoupdate"
tar -czf - $UPDATE_BUNDLE_FILE | sshpass -p $PASS ssh -o StrictHostKeyChecking=no ${USER}@${HOST} "mkdir -p build_server/lts/${REF}/autoupdate; tar -xzf - -C build_server/lts/${REF}/autoupdate"
RET=$((RET+$?+PIPESTATUS))
else
tar -czf - $FULL_BUNDLE_FILE | sshpass -p $RUSEFI_SSH_PASS ssh -o StrictHostKeyChecking=no $RUSEFI_SSH_USER@$RUSEFI_SSH_SERVER "tar -xzf - -C build_server"
tar -czf - $FULL_BUNDLE_FILE | sshpass -p $PASS ssh -o StrictHostKeyChecking=no ${USER}@${HOST} "tar -xzf - -C build_server"
RET=$((RET+$?+PIPESTATUS))
tar -czf - $UPDATE_BUNDLE_FILE | sshpass -p $RUSEFI_SSH_PASS ssh -o StrictHostKeyChecking=no $RUSEFI_SSH_USER@$RUSEFI_SSH_SERVER "mkdir -p build_server/autoupdate; tar -xzf - -C build_server/autoupdate"
tar -czf - $UPDATE_BUNDLE_FILE | sshpass -p $PASS ssh -o StrictHostKeyChecking=no ${USER}@${HOST} "mkdir -p build_server/autoupdate; tar -xzf - -C build_server/autoupdate"
RET=$((RET+$?+PIPESTATUS))
fi
if [ $RET -ne 0 ]; then