Skip to content

Merge pull request #32 from CoderBotOrg/feat/add_environments #32

Merge pull request #32 from CoderBotOrg/feat/add_environments

Merge pull request #32 from CoderBotOrg/feat/add_environments #32

# 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
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: deploy-release
on:
push:
branches: [ main ]
jobs:
deploy-release:
strategy:
max-parallel: 3
matrix:
device:
- type: raspberrypi3
fleet: info319/coderbot_test
#- type: raspberrypi3-64
# fleet: info319/coderbot_pi3_64_test
#- type: raspberrypi0-2w-64
# fleet: info319/coderbot_pi0w2_64_test
runs-on: ubuntu-latest
environment: test
outputs:
release_id: ${{ steps.build.outputs.release_id }}
steps:
- uses: actions/checkout@v3 # Checking out the repo
- uses: balena-io/[email protected]
id: build
with:
balena_token: ${{ secrets.BALENA_TOKEN }}
fleet: ${{ matrix.device.fleet }}
registry_secrets: ${{ secrets.GHCR_CREDS }}
source: .
- name: Log release ID built
run: echo "Built release version ${{ steps.build.outputs.release_id }}"
build-balena:
strategy:
matrix:
device:
- type: raspberrypi3
version: v5.3.7.dev
fleet: info319/coderbot_test
#- type: raspberrypi3-64
# version: v5.0.8.dev
# fleet: info319/coderbot_pi3_64_test
#- type: raspberrypi0-2w-64
# version: v5.1.47.dev
# fleet: info319/coderbot_pi0w2_64_test
env:
IMAGE_NAME: coderbot_${{ matrix.device.type }}.img
DEVICE_TYPE: ${{ matrix.device.type }}
DEVICE_VERSION: ${{ matrix.device.version }}
BALENA_FLEET: ${{ matrix.device.fleet }}
needs: deploy-release
runs-on: ubuntu-latest
environment: test
steps:
- uses: actions/checkout@v3 # Checking out the repo
- 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
- run: unzip balena-cli-v14.4.1-linux-x64-standalone.zip
- run: export PATH=$PATH:$(pwd)/balena-cli
- run: ./balena-cli/balena --version
- run: ./balena-cli/balena login --token ${{ secrets.BALENA_TOKEN }}
- run: ./balena-cli/balena os download $DEVICE_TYPE --version $DEVICE_VERSION --output $IMAGE_NAME
- run: sudo mkdir /mnt/resin-boot
- run: sudo mount -o loop,offset=$(( 512 * 8192)) $IMAGE_NAME /mnt/resin-boot
- run: sudo cp rpi/config.txt /mnt/resin-boot
- run: sudo umount /mnt/resin-boot
- run: ./balena-cli/balena config generate --version $DEVICE_VERSION --deviceType $DEVICE_TYPE --fleet $BALENA_FLEET --network ethernet --appUpdatePollInterval 10 --dev -o config.json
- run: ./balena-cli/balena os configure $IMAGE_NAME --fleet $BALENA_FLEET --config config.json --config-network ethernet
- run: sudo ./balena-cli/balena config write --drive $IMAGE_NAME hostname coderbot
- 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
- run: ./balena-cli/balena preload $IMAGE_NAME --fleet $BALENA_FLEET -c $RELEASE_COMMIT
- run: mkdir -p dist
- run: mv $IMAGE_NAME ./dist/.
- name: Archive dist
uses: actions/upload-artifact@v3
with:
name: image-preloaded
path: dist