|
| 1 | +# This workflow will do a clean install of node dependencies, cache/restore them, build the source code and run tests across different versions of node |
| 2 | +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions |
| 3 | + |
| 4 | +name: deploy-release |
| 5 | + |
| 6 | +on: |
| 7 | + push: |
| 8 | + branches: [ main64 ] |
| 9 | + |
| 10 | +jobs: |
| 11 | + deploy-release: |
| 12 | + strategy: |
| 13 | + max-parallel: 3 |
| 14 | + matrix: |
| 15 | + device: |
| 16 | + # - type: raspberrypi3 |
| 17 | + # fleet: info319/coderbot_test |
| 18 | + - type: raspberrypi3-64 |
| 19 | + fleet: info319/coderbot_pi3_64_test |
| 20 | + - type: raspberrypi0-2w-64 |
| 21 | + fleet: info319/coderbot_pi0w2_64_test |
| 22 | + runs-on: ubuntu-latest |
| 23 | + environment: test |
| 24 | + outputs: |
| 25 | + release_id: ${{ steps.build.outputs.release_id }} |
| 26 | + steps: |
| 27 | + - uses: actions/checkout@v3 # Checking out the repo |
| 28 | + - uses: balena-io/deploy-to-balena-action@v2.0.45 |
| 29 | + id: build |
| 30 | + with: |
| 31 | + balena_token: ${{ secrets.BALENA_TOKEN }} |
| 32 | + fleet: ${{ matrix.device.fleet }} |
| 33 | + registry_secrets: ${{ secrets.GHCR_CREDS }} |
| 34 | + source: . |
| 35 | + - name: Log release ID built |
| 36 | + run: echo "Built release version ${{ steps.build.outputs.release_id }}" |
| 37 | + |
| 38 | + build-balena: |
| 39 | + strategy: |
| 40 | + matrix: |
| 41 | + device: |
| 42 | + # - type: raspberrypi3 |
| 43 | + # version: v5.3.21.dev |
| 44 | + # fleet: info319/coderbot_test |
| 45 | + - type: raspberrypi3-64 |
| 46 | + version: 6.5.9+rev5.dev |
| 47 | + fleet: info319/coderbot_pi3_64_test |
| 48 | + - type: raspberrypi0-2w-64 |
| 49 | + version: 6.5.9+rev5.dev |
| 50 | + fleet: info319/coderbot_pi0w2_64_test |
| 51 | + env: |
| 52 | + IMAGE_NAME: coderbot_${{ matrix.device.type }}.img |
| 53 | + DEVICE_TYPE: ${{ matrix.device.type }} |
| 54 | + DEVICE_VERSION: ${{ matrix.device.version }} |
| 55 | + BALENA_FLEET: ${{ matrix.device.fleet }} |
| 56 | + needs: deploy-release |
| 57 | + runs-on: ubuntu-latest |
| 58 | + environment: test |
| 59 | + steps: |
| 60 | + - uses: actions/checkout@v3 # Checking out the repo |
| 61 | + - run: wget https://github.com/balena-io/balena-cli/releases/download/v18.0.0/balena-cli-v18.0.0-linux-x64-standalone.zip -O balena-cli-v14.4.1-linux-x64-standalone.zip |
| 62 | + - run: unzip balena-cli-v14.4.1-linux-x64-standalone.zip |
| 63 | + - run: export PATH=$PATH:$(pwd)/balena-cli |
| 64 | + - run: ./balena-cli/balena --version |
| 65 | + - run: ./balena-cli/balena login --token ${{ secrets.BALENA_TOKEN }} |
| 66 | + - run: ./balena-cli/balena os download $DEVICE_TYPE --version $DEVICE_VERSION --output $IMAGE_NAME |
| 67 | + - run: sudo mkdir /mnt/resin-boot |
| 68 | + - run: sudo mount -o loop,offset=$(( 512 * 8192)) $IMAGE_NAME /mnt/resin-boot |
| 69 | + - run: sudo cp rpi/config.txt /mnt/resin-boot |
| 70 | + - run: sudo umount /mnt/resin-boot |
| 71 | + - run: ./balena-cli/balena config generate --version $DEVICE_VERSION --deviceType $DEVICE_TYPE --fleet $BALENA_FLEET --network ethernet --appUpdatePollInterval 10 --dev -o config.json |
| 72 | + - run: ./balena-cli/balena os configure $IMAGE_NAME --fleet $BALENA_FLEET --config config.json --config-network ethernet |
| 73 | + - run: sudo ./balena-cli/balena config write --drive $IMAGE_NAME hostname coderbot |
| 74 | + - run: echo "RELEASE_COMMIT=current" >> $GITHUB_ENV #echo "RELEASE_COMMIT=$(./balena-cli/balena release ${{ needs.deploy-release.outputs.release_id }}|grep 'COMMIT'|awk '{print $2}')" >> $GITHUB_ENV |
| 75 | + - run: ./balena-cli/balena preload $IMAGE_NAME --fleet $BALENA_FLEET -c $RELEASE_COMMIT |
| 76 | + - run: mkdir -p dist |
| 77 | + - run: mv $IMAGE_NAME ./dist/. |
| 78 | + - name: Archive dist |
| 79 | + uses: actions/upload-artifact@v3 |
| 80 | + with: |
| 81 | + name: image-preloaded |
| 82 | + path: dist |
0 commit comments