diff --git a/.github/workflows/build-open-fleet.yml b/.github/workflows/build-open-fleet.yml index 5eb5524..37117e8 100644 --- a/.github/workflows/build-open-fleet.yml +++ b/.github/workflows/build-open-fleet.yml @@ -6,11 +6,13 @@ on: workflow_dispatch: env: - balena-cli: v16.1.0 + balena-cli: v16.6.0 raspberrypi3-64: 2.114.18 raspberrypi4-64: 2.115.1 raspberrypicm4-ioboard: 2.112.12 rockpi-4b-rk3399: 2.108.25+rev1 + balena-bobcat-image: 2023.06.25 + bobcat-px30: 2.115.3 cloud: nebra-cloud jobs: @@ -62,7 +64,7 @@ jobs: miner="$(echo ${{ github.event.repository.name }} | cut -d '-' -f2-)" echo "Repo: $miner" - if [[ "$miner" =~ "nebra" ]] ; then + if [[ "$miner" =~ "nebra" ]] || [[ "$miner" =~ "bobcat" ]] ; then variant="$miner" elif [[ "$miner" == "og" ]] ; then variant="helium-fl1" @@ -131,6 +133,16 @@ jobs: sudo ln -s /opt/balena-cli/balena /usr/bin/ cd ~ + - name: Download base Balena OS image + uses: dsaltares/fetch-gh-release-asset@master + if: github.event.repository.name == 'helium-bobcat-px30' && env.BRANCH == 'master' + with: + repo: 'NebraLtd/balena-bobcat-px30' + version: 'tags/${{ env.balena-bobcat-image }}' + file: 'balena-image-bobcat-px30-${{ env.balena-bobcat-image }}.img.zip' + target: 'images/balena-base-${{ github.event.repository.name }}.img.zip' + token: ${{ secrets.MR_BUMP }} + - name: Generate a Balena OS image for the given board, variant, frequency if: env.BRANCH == 'master' run: | @@ -174,6 +186,9 @@ jobs: elif [ ${{ github.event.repository.name }} == 'helium-syncrobit' ] || [ ${{ github.event.repository.name }} == 'helium-linxdot' ] || [ ${{ github.event.repository.name }} == 'helium-pycom' ] || [ ${{ github.event.repository.name }} == 'helium-midas' ] ; then balena_os="raspberrypicm4-ioboard" balena_os_version="${{ env.raspberrypicm4-ioboard }}" + elif [ ${{ github.event.repository.name }} == 'helium-bobcat-px30' ] ; then + balena_os="isg-503" + balena_os_version="${{ env.bobcat-px30 }}" elif [ ${{ env.ROCKPI }} == 'YES' ] ; then balena_os="rockpi-4b-rk3399" balena_os_version="${{ env.rockpi-4b-rk3399 }}" @@ -189,10 +204,15 @@ jobs: fi if $NODRYRUN ; then - # Download the base image - balena os download "$balena_os" \ - -o "$base_image_path" \ - --version "$balena_os_version" + if [ ${{ github.event.repository.name }} != 'helium-bobcat-px30' ] ; then + # Download the base image + balena os download "$balena_os" \ + -o "$base_image_path" \ + --version "$balena_os_version" + else + unzip $IMAGE_BASE_PATH/*.zip -d $IMAGE_BASE_PATH/ + mv ${IMAGE_BASE_PATH}/*.img ${base_image_path} + fi fi echo "IMAGE_BASE_PATH=$IMAGE_BASE_PATH" >> $GITHUB_ENV @@ -246,10 +266,14 @@ jobs: fi if $NODRYRUN ; then - balena os configure "$image_path" \ - --fleet "nebraltd/$fleet_name" \ - --config-network ethernet \ - --version "${{ env.balena_os_version }}" + if [ ${{ github.event.repository.name }} != 'helium-bobcat-px30' ] ; then + balena os configure "$image_path" \ + --fleet "nebraltd/$fleet_name" \ + --config-network ethernet \ + --version "${{ env.balena_os_version }}" + else + sudo balena config inject ${GITHUB_WORKSPACE}/config.json --drive "${image_path}" + fi fi if $VERBOSE ; then @@ -276,6 +300,23 @@ jobs: sudo balena config inject $final_json_filename --drive "$image_path" fi + if [ ${{ github.event.repository.name }} == 'helium-bobcat-px30' ] ; then + # Overwrite device type from "bobcat-px30" to "isg-503" + if $VERBOSE ; then + echo "Overwriting device-type" + fi + + if $NODRYRUN ; then + sudo losetup -P -f "${image_path}" + loop_dev=$(losetup -l | grep $(basename "${image_path}") | cut -d ' ' -f 1) + tmpdir=$(mktemp -d) + sudo mount ${loop_dev}p1 ${tmpdir} + sudo sed -i 's/"slug": "bobcat-px30"/"slug": "isg-503"/' ${tmpdir}/device-type.json + sudo umount ${tmpdir} + sudo losetup -d ${loop_dev} + fi + fi + # Copy configuration files into boot and root partition of the balena image if $VERBOSE ; then diff --git a/.github/workflows/update-files.yml b/.github/workflows/update-files.yml index bdd6d19..2d1c62e 100644 --- a/.github/workflows/update-files.yml +++ b/.github/workflows/update-files.yml @@ -24,12 +24,14 @@ jobs: miner="$(echo ${{ github.event.repository.name }} | cut -d '-' -f2-)" echo "Repo: $miner" - wget https://raw.githubusercontent.com/NebraLtd/helium-miner-software/production/balena/balena.yml."$miner" -O balena.yml - wget https://raw.githubusercontent.com/NebraLtd/helium-miner-software/production/balena/workflows/balena-app.yml -O .github/workflows/balena-app.yml + if [ $miner != 'bobcat-px30' ] ; then + wget https://raw.githubusercontent.com/NebraLtd/helium-miner-software/production/balena/balena.yml."$miner" -O balena.yml + wget https://raw.githubusercontent.com/NebraLtd/helium-miner-software/production/balena/workflows/balena-app.yml -O .github/workflows/balena-app.yml + wget https://raw.githubusercontent.com/NebraLtd/helium-miner-software/production/balena/workflows/update-action-prod.yml -O workflows/update-action-prod.yml + wget https://raw.githubusercontent.com/NebraLtd/helium-miner-software/production/balena/workflows/update-action-test.yml -O workflows/update-action-test.yml + fi wget https://raw.githubusercontent.com/NebraLtd/helium-miner-software/production/balena/workflows/update-files.yml -O .github/workflows/update-files.yml wget https://raw.githubusercontent.com/NebraLtd/helium-miner-software/production/balena/workflows/build-open-fleet.yml -O .github/workflows/build-open-fleet.yml - wget https://raw.githubusercontent.com/NebraLtd/helium-miner-software/production/balena/workflows/update-action-prod.yml -O workflows/update-action-prod.yml - wget https://raw.githubusercontent.com/NebraLtd/helium-miner-software/production/balena/workflows/update-action-test.yml -O workflows/update-action-test.yml wget https://raw.githubusercontent.com/NebraLtd/helium-miner-software/production/balena/ssh/ssh_public_keys.json -O ssh_public_keys.json if [ $miner == 'pisces' ] ; then @@ -44,7 +46,7 @@ jobs: wget https://raw.githubusercontent.com/NebraLtd/helium-miner-software/production/balena/config/config.txt.sensecap -O config.txt elif [ $miner == 'risinghf' ] ; then wget https://raw.githubusercontent.com/NebraLtd/helium-miner-software/production/balena/config/config.txt.risinghf -O config.txt - elif [ $miner == 'nebra-indoor2' ] || [ $miner == 'nebra-outdoor2' ] || [ $miner == 'linxdot-rkcm3' ] || [ $miner == 'syncrobit-rkcm3' ] ; then + elif [ $miner == 'nebra-indoor2' ] || [ $miner == 'nebra-outdoor2' ] || [ $miner == 'linxdot-rkcm3' ] || [ $miner == 'syncrobit-rkcm3' ] || [ $miner == 'bobcat-px30' ] ; then echo "No config.txt file needed - not RasPi based." else wget https://raw.githubusercontent.com/NebraLtd/helium-miner-software/production/balena/config/config.txt.rak -O config.txt @@ -55,7 +57,7 @@ jobs: with: branch: master file-path: | - balena.yml + balena.ym* config.* .github/workflows/*.yml ssh_public_keys.json @@ -81,12 +83,14 @@ jobs: miner="$(echo ${{ github.event.repository.name }} | cut -d '-' -f2-)" echo "Repo: $miner" - wget https://raw.githubusercontent.com/NebraLtd/helium-miner-software/master/balena/balena.yml."$miner" -O balena.yml - wget https://raw.githubusercontent.com/NebraLtd/helium-miner-software/master/balena/workflows/balena-app.yml -O .github/workflows/balena-app.yml + if [ $miner != 'bobcat-px30' ] ; then + wget https://raw.githubusercontent.com/NebraLtd/helium-miner-software/master/balena/balena.yml."$miner" -O balena.yml + wget https://raw.githubusercontent.com/NebraLtd/helium-miner-software/master/balena/workflows/balena-app.yml -O .github/workflows/balena-app.yml + wget https://raw.githubusercontent.com/NebraLtd/helium-miner-software/master/balena/workflows/update-action-prod.yml -O workflows/update-action-prod.yml + wget https://raw.githubusercontent.com/NebraLtd/helium-miner-software/master/balena/workflows/update-action-test.yml -O workflows/update-action-test.yml + fi wget https://raw.githubusercontent.com/NebraLtd/helium-miner-software/master/balena/workflows/update-files.yml -O .github/workflows/update-files.yml wget https://raw.githubusercontent.com/NebraLtd/helium-miner-software/master/balena/workflows/build-open-fleet.yml -O .github/workflows/build-open-fleet.yml - wget https://raw.githubusercontent.com/NebraLtd/helium-miner-software/master/balena/workflows/update-action-prod.yml -O workflows/update-action-prod.yml - wget https://raw.githubusercontent.com/NebraLtd/helium-miner-software/master/balena/workflows/update-action-test.yml -O workflows/update-action-test.yml wget https://raw.githubusercontent.com/NebraLtd/helium-miner-software/master/balena/ssh/ssh_public_keys.json -O ssh_public_keys.json if [ $miner == 'pisces' ] ; then @@ -101,7 +105,7 @@ jobs: wget https://raw.githubusercontent.com/NebraLtd/helium-miner-software/master/balena/config/config.txt.sensecap -O config.txt elif [ $miner == 'risinghf' ] ; then wget https://raw.githubusercontent.com/NebraLtd/helium-miner-software/master/balena/config/config.txt.risinghf -O config.txt - elif [ $miner == 'nebra-indoor2' ] || [ $miner == 'nebra-outdoor2' ] || [ $miner == 'linxdot-rkcm3' ] || [ $miner == 'syncrobit-rkcm3' ] ; then + elif [ $miner == 'nebra-indoor2' ] || [ $miner == 'nebra-outdoor2' ] || [ $miner == 'linxdot-rkcm3' ] || [ $miner == 'syncrobit-rkcm3' ] || [ $miner == 'bobcat-px30' ] ; then echo "No config.txt file needed - not RasPi based." else wget https://raw.githubusercontent.com/NebraLtd/helium-miner-software/master/balena/config/config.txt.rak -O config.txt @@ -112,7 +116,7 @@ jobs: with: branch: testnet file-path: | - balena.yml + balena.ym* config.* .github/workflows/*.yml ssh_public_keys.json