-
-
Notifications
You must be signed in to change notification settings - Fork 49
96 lines (80 loc) · 3.53 KB
/
push-to-prod-nebraos-cloud.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
name: NebraOS Cloud Deploy (Production)
on:
push:
# Only run workflow for pushes to specific files on production branch
paths:
- 'settings.ini'
- 'templates/**'
workflow_dispatch:
jobs:
build-prod:
if: github.ref_name == 'production' || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
strategy:
max-parallel: 1
fail-fast: false
matrix:
sbc: [nebra-indoor1, nebra-outdoor1, nebra-indoor2, nebra-outdoor2, rak, pisces, og, sensecap, finestra, controllino, cotx, pantherx1, linxdot, linxdot-rk3566, pycom, syncrobit, syncrobit-rkcm3, risinghf, midas, bobcat-px30, bobcat-rk3566]
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: production
- name: Setup Python Libraries
run: pip install -r requirements.txt
- name: Export short SHA of current commit
shell: bash
run: |
FIRMWARE_SHORT_HASH=$( echo ${GITHUB_SHA:0:7} )
echo "FIRMWARE_SHORT_HASH=$FIRMWARE_SHORT_HASH" >> $GITHUB_ENV
# Get the latest GA release and branch
source <(grep FIRMWARE_VERSION settings.ini)
LATEST_GA=$FIRMWARE_VERSION
GITHUB_BRANCH=$( echo "${{ github.ref }}" | sed 's/refs\/heads\///g' )
echo "timestamp=$(date +'%s')" >> $GITHUB_ENV
echo "day=$(date +'%F')" >> $GITHUB_ENV
echo "LATEST_GA=$LATEST_GA" >> $GITHUB_ENV
echo "GITHUB_BRANCH=$GITHUB_BRANCH" >> $GITHUB_ENV
- name: Generate Docker Compose
run: |
miner="${{ matrix.sbc }}"
repo="helium-$miner"
if [[ "$miner" == "nebra-indoor1" ]] || [[ "$miner" == "nebra-indoor2" ]] || [[ "$miner" == "nebra-outdoor1" ]] || [[ "$miner" == "nebra-outdoor2" ]] || [[ "$miner" == "bobcat-px30" ]] || [[ "$miner" == "bobcat-rk3566" ]] ; then
variant="$miner"
elif [[ "$miner" == "og" ]] ; then
variant="helium-fl1"
else
variant="$miner-fl1"
fi
echo "Variant: $variant"
echo "REPO=$repo" >> $GITHUB_ENV
echo "Repo: $repo"
FIRMWARE_SHORT_HASH=${{ env.FIRMWARE_SHORT_HASH }}
python gen_docker_compose_by_variant.py "$variant" -o docker-compose.yml
- name: Balena Deploy
uses: nebraltd/[email protected]
with:
balena_api_token: ${{secrets.NEBRAOS_CLOUD_TOKEN}}
balena_url: cloud.nebra.com
balena_command: "deploy nebraltd/${{ env.REPO }} --debug --nocache --build"
- name: Upload docker-compose.yml artifact
uses: actions/upload-artifact@v3
with:
name: docker-compose.yml.${{ env.REPO }}
path: docker-compose.yml
- name: Upload docker-compose.yml to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: docker-compose.yml
asset_name: docker-compose.yml.${{ env.REPO }}
tag: ${{ env.LATEST_GA }}-${{ env.day }}
overwrite: true
body: "This is helium-miner-software release ${{ env.LATEST_GA }}-${{ env.day }}"
- name: Trigger build action in ${{ env.REPO }} repo
uses: peter-evans/repository-dispatch@v2
with:
token: ${{ secrets.MR_BUMP }}
event-type: build-open-fleet
repository: NebraLtd/${{ env.REPO }}
client-payload: '{"release": "${{ env.LATEST_GA }}_GA", "tag": "${{ env.LATEST_GA }}", "firmware": "${{ env.FIRMWARE_SHORT_HASH }}", "branch": "${{ env.GITHUB_BRANCH }}"}'