-
Notifications
You must be signed in to change notification settings - Fork 0
197 lines (176 loc) · 6.64 KB
/
build.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
name: Build Image
on:
workflow_dispatch:
inputs:
build_alpha:
description: 'Alpha build true/false default: false'
required: false
default: false
push:
branches:
- mrbeam2-stable
paths-ignore:
- '*.rst'
- '*.md'
pull_request:
branches: [develop, mrbeam2-stable]
env:
VARIANT: beamos
jobs:
set_matrix:
name: Configure the matrix of image flavors to build.
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- id: set-matrix
if:
run: |
if [ "${{ github.event.inputs.build_alpha }}" = "true" ]
then
flavors='{"flavor":"alpha 2Q"}'
else
flavors='{"flavor":"migrationOS"}'
fi
echo "matrix={\"include\":[$flavors]}" >> $GITHUB_OUTPUT
build:
needs: set_matrix
runs-on: ubuntu-latest
strategy:
matrix: ${{fromJson(needs.set_matrix.outputs.matrix)}}
# flavors: ["2S", "2R", "develop 2R"]
# flavors: ["develop 2S"]
steps:
- name: Install Dependencies
run: |
sudo apt update
sudo apt install coreutils p7zip-full qemu-user-static
- name: Configure SSH-Keys inside image
env:
SSH_KEY_MOUNTMANAGER: ${{ secrets.DEPLOY_KEY_MOUNTMANAGER }}
SSH_KEY_MRBCHECK: ${{ secrets.DEPLOY_KEY_MRBCHECK }}
SSH_KEY_BITBUCKET: ${{ secrets.BITBUCKET_ACCESS_KEY }}
run: |
mkdir -p ~/.ssh/
echo "$SSH_KEY_BITBUCKET" > ~/.ssh/bitbucket.key
echo "$SSH_KEY_MOUNTMANAGER" > ~/.ssh/mountmanager.key
echo "$SSH_KEY_MRBCHECK" > ~/.ssh/mrbcheck.key
chmod 600 ~/.ssh/bitbucket.key
chmod 600 ~/.ssh/mountmanager.key
chmod 600 ~/.ssh/mrbcheck.key
touch ~/.ssh/known_hosts
ssh-keygen -R bitbucket.org
ssh-keygen -R github.com
ssh-keyscan -H bitbucket.org >> ~/.ssh/known_hosts
ssh-keyscan -H github.com >> ~/.ssh/known_hosts
cat >>~/.ssh/config <<END
Host bitbucket.org
HostName bitbucket.org
IdentityFile ~/.ssh/bitbucket.key
Host github.com-mountmanager
HostName github.com
IdentityFile ~/.ssh/mountmanager.key
Host github.com-mrb_check
HostName github.com
IdentityFile ~/.ssh/mrbcheck.key
END
- name: Checkout CustomPiOS
uses: actions/checkout@v4
with:
repository: 'mrbeam/CustomPiOS'
path: CustomPiOS
ref: 'test_devpi_josef'
- name: Checkout Project Repository
uses: actions/checkout@v4
with:
submodules: recursive
path: repository
- name: Write submodule info to separate files outside chroot
run: |
cd repository
git --no-pager submodule foreach 'git branch | tail -n 1 | tee current_branch'
git --no-pager submodule foreach 'git rev-parse HEAD | tee current_commit_hash'
- name: Download Raspbian Image
run: |
cd repository/src/image
wget -c --trust-server-names 'https://downloads.raspberrypi.org/raspios_lite_armhf/images/raspios_lite_armhf-2021-05-28/2021-05-07-raspios-buster-armhf-lite.zip'
- name: Update CustomPiOS Paths
run: |
cd repository/src
../../CustomPiOS/src/update-custompios-paths
- name: Force apt mirror to work around intermittent mirror hiccups
run: |
echo "OCTOPI_APTMIRROR=http://mirror.us.leaseweb.net/raspbian/raspbian" > repository/src/config.local
- name: Download the Beam OS 2 Image
uses: actions-hub/gcloud@master
env:
PROJECT_ID: devpi-310008
APPLICATION_CREDENTIALS: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS_DOWNLOAD }}
with:
args: cp "${{ vars.BEAMOS2_IMAGE }}" repository/src/image/
cli: gsutil
- name: Extract the Beam OS 2 Image
id: extract_the_image
run: |
# Set the image file
the_image=$(basename "${{ vars.BEAMOS2_IMAGE }}")
source_dir="repository/src/image"
echo "The Beam OS 2 Image: ${the_image}"
target_dir="repository/src/modules/beamos/filesystem/migration/home/pi/image"
target_name="beamos2.wic"
# Extract bz2 file into target_dir
tar -xjf ${source_dir}/${the_image} -C $target_dir
# Rename the extracted image to beamos2.wic[bz2, bmap] and remove other files
mv ${target_dir}/mrbeam-image-*.wic.bz2 ${target_dir}/${target_name}.bz2
mv ${target_dir}/mrbeam-image-*.wic.bmap ${target_dir}/${target_name}.bmap
rm ${target_dir}/mrbeam-*
echo "Placed the image in ${target_dir}/${target_name}.bz2 with bmap file"
- name: Build Image (MrBeam Variant)
env:
PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
run: |
sudo modprobe loop
cd repository/src
echo "export EXTRA_SSH_KEY='${{ secrets.SSH_BEAMOS01_RSA }}'" >> config
echo "export PERSONAL_ACCESS_TOKEN='${{ secrets.PERSONAL_ACCESS_TOKEN }}'" >> config
sudo bash -x ./build_dist $VARIANT ${{ matrix.flavor }}
- name: Copy output
id: copy
run: |
source repository/src/config
source repository/src/variants/beamos/config
NOW=$(date +"%Y-%m-%d-%H%M")
# When building a variant, it is built in workspace-$VARIANT
if [ -n $VARIANT ]; then
[ -n "${{ matrix.flavor }}" ] && FL="$(echo ${{ matrix.flavor }} | sed 's/ /-/g')-"
IMAGE=$NOW-$VARIANT-$FL$DIST_VERSION
BRANCH_NAME=${GITHUB_REF##*/}
if [[ "$BRANCH_NAME" != "mrbeam" ]]; then
IMAGE=$IMAGE-$BRANCH_NAME
fi
cp repository/src/workspace-$VARIANT/*.img $IMAGE.img
else
IMAGE=$NOW-octopi-$DIST_VERSION
cp repository/src/workspace/*.img $IMAGE.img
fi
echo "image=$IMAGE" >> $GITHUB_OUTPUT
# # artifact upload will take care of zipping for us
# - uses: actions/upload-artifact@v1
# # if: github.event_name == 'schedule'
# with:
# name: ${{ steps.copy.outputs.image }}
# path: ${{ steps.copy.outputs.image }}.img
- name: Compress output
run: |
zip -r ${{ steps.copy.outputs.image }}.zip ${{ steps.copy.outputs.image }}.img
- name: Create env variable for upload folder in gcloud bucket
run: |
# Use the last letter of the flavor for the directory name
echo "DIR=$(echo ${{ matrix.flavor }})" >> $GITHUB_ENV
- uses: actions-hub/gcloud@master
env:
PROJECT_ID: devpi-310008
APPLICATION_CREDENTIALS: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}
with:
args: cp ${{ steps.copy.outputs.image }}.zip gs://beamos_images/${{ env.DIR }}/
cli: gsutil