1
+ name : Update download JSON index
2
+ on :
3
+ repository_dispatch :
4
+ types : ["Webindex update"]
5
+ workflow_dispatch :
6
+ push :
7
+
8
+ concurrency :
9
+ group : redirector
10
+ cancel-in-progress : false
11
+
12
+ jobs :
13
+
14
+ Check :
15
+
16
+ name : " Check membership"
17
+ runs-on : " ubuntu-24.04"
18
+ steps :
19
+
20
+ - name : " Check membership"
21
+ uses : armbian/actions/team-check@main
22
+ with :
23
+ ORG_MEMBERS : ${{ secrets.ORG_MEMBERS }}
24
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
25
+ TEAM : " Release manager"
26
+
27
+ Webindex :
28
+
29
+ env :
30
+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
31
+
32
+ name : " Generate JSON Index"
33
+ runs-on : " ubuntu-24.04"
34
+ needs : Check
35
+ steps :
36
+
37
+ - name : Checkout build framework repository
38
+ uses : actions/checkout@v4
39
+ with :
40
+ repository : armbian/build
41
+ fetch-depth : 1
42
+ clean : false
43
+ path : build
44
+
45
+ - name : Checkout OS repository
46
+ uses : actions/checkout@v4
47
+ with :
48
+ repository : armbian/os
49
+ fetch-depth : 1
50
+ clean : false
51
+ path : os
52
+
53
+ - name : Checkout armbian.github.io repository
54
+ uses : actions/checkout@v4
55
+ with :
56
+ repository : armbian/armbian.github.io
57
+ fetch-depth : 0
58
+ clean : false
59
+ path : armbian.github.io
60
+
61
+ - name : Install SSH key
62
+ uses : shimataro/ssh-key-action@v2
63
+ with :
64
+ key : ${{ secrets.KEY_UPLOAD }}
65
+ known_hosts : ${{ secrets.KNOWN_HOSTS_ARMBIAN_UPLOAD }}
66
+ if_key_exists : replace
67
+
68
+ - name : " Install dependencies"
69
+ uses : awalsh128/cache-apt-pkgs-action@latest
70
+ with :
71
+ packages : gh jc zip
72
+ version : 1.0
73
+
74
+ - name : " Generate map file"
75
+ run : |
76
+
77
+ # make sure its cleaned
78
+ rm -f exposed.map.autoproposal
79
+
80
+ # get all stable files we provide
81
+ rsync -e "ssh -p 10023 -o StrictHostKeyChecking=accept-new" -ar [email protected] :/storage/www/dl/ | awk '{ print $5 }' | grep "archive/" | grep -v ".txt\|.xz.\|homeassistant\|openhab\|kali\|omv" | grep ".xz" > /tmp/stable.txt
82
+
83
+ # generate map entries
84
+ # $1 = board
85
+ # $2 = branch
86
+ function check_targets(){
87
+ b=$(echo $1 | rev | cut -d"/" -f1 | rev | cut -d"." -f1)
88
+ I=0
89
+ for bs in $(cat /tmp/stable.txt | grep ${b}/); do
90
+ GNOME=$(echo $bs | grep "$2" | grep _gnome | grep jammy | sed 's/[^0-9]\([0-9]*\.[0-9]*\.[0-9]*\)_/_[0-9].*/' | sed 's/[^0-9]\([0-9]*\.[0-9]*\.[0-9]*\)/_[0-9]*\.[0-9]*\.[0-9]*/')
91
+ [[ -n $GNOME ]] && echo $GNOME && I=$(( I + 1 ))
92
+ XFCE=$(echo $bs | grep $2 | grep _xfce | grep jammy | sed 's/[^0-9]\([0-9]*\.[0-9]*\.[0-9]*\)_/_[0-9].*/' | sed 's/[^0-9]\([0-9]*\.[0-9]*\.[0-9]*\)/_[0-9]*\.[0-9]*\.[0-9]*/')
93
+ [[ -n $XFCE ]] && echo $XFCE && I=$(( I + 1 ))
94
+ SERVER=$(echo $bs | grep $2 | grep -v "minimal\|desktop" | grep bookworm | sed 's/[^0-9]\([0-9]*\.[0-9]*\.[0-9]*\)_/_[0-9].*/' | sed 's/[^0-9]\([0-9]*\.[0-9]*\.[0-9]*\)/_[0-9]*\.[0-9]*\.[0-9]*/' )
95
+ [[ -n ${SERVER} ]] && echo $SERVER && I=$(( I + 1 ))
96
+ [[ $I -eq 2 ]] && break
97
+ done
98
+ JAMMYCLI=$(cat /tmp/stable.txt | grep $b | grep $2 | grep -v "minimal\|desktop" | grep jammy | sed 's/[^0-9]\([0-9]*\.[0-9]*\.[0-9]*\)_/_[0-9].*/' | sed 's/[^0-9]\([0-9]*\.[0-9]*\.[0-9]*\)/_[0-9]*\.[0-9]*\.[0-9]*/' )
99
+ [[ $I -lt 2 && -n $JAMMYCLI ]] && echo "$JAMMYCLI"
100
+ return $I
101
+ }
102
+
103
+ for board in $(ls -1 build/config/boards/*.{conf,csc,wip,tvb}); do
104
+ # read kernel target
105
+ if [[ $(grep KERNEL_TARGET -w $board | cut -d '"' -f 2 | sed "s/,/ /g" | wc -w) -gt 2 ]]; then
106
+ KERNEL_TARGET=$(grep KERNEL_TARGET -w $board | cut -d '"' -f 2 | awk -F, '{ print $1,$3,$2 }')
107
+ else
108
+ KERNEL_TARGET=$(grep KERNEL_TARGET -w $board | cut -d '"' -f 2 | sed "s/,/ /g")
109
+ fi
110
+ VARIANTS=0
111
+ for targets in ${KERNEL_TARGET}; do
112
+ if [[ "${targets}" == current && $VARIANTS -lt 2 ]]; then
113
+ check_targets "$board" "current"
114
+ VARIANTS=$((VARIANTS+$?))
115
+ fi
116
+ if [[ "${targets}" == legacy && $VARIANTS -lt 2 ]]; then
117
+ check_targets "$board" "legacy"
118
+ VARIANTS=$((VARIANTS+$?))
119
+ fi
120
+ if [[ "${targets}" == edge && $VARIANTS -lt 2 ]]; then
121
+ check_targets "$board" "edge"
122
+ VARIANTS=$((VARIANTS+$?))
123
+ fi
124
+ done || true
125
+ done | tee -a > exposed.map.autoproposal
126
+ #
127
+ # Lets fix this and go back to manual in case of troubles
128
+ # cp exposed.map.autoproposal os/exposed.map
129
+
130
+ - name : " Build JSON file" # adjust "exposed" property while reading from download
131
+ run : |
132
+
133
+ # prepare feeds
134
+ #A=$(rsync -ar rsync://rsync.armbian.com/dl/ | awk '{ print ""$2"|https://dl.armbian.com/"$5"|"$3"T"$4"Z" }' | grep "archive/" | grep -v ".txt")
135
+ A=$(rsync -e "ssh -p 10023 -o StrictHostKeyChecking=accept-new" -ar [email protected] :/storage/www/dl/ | awk '{ print ""$2"|https://dl.armbian.com/"$5"|"$3"T"$4"Z" }' | grep "archive/" | grep -v ".txt\|homeassistant\|openhab\|kali\|omv")
136
+ B=$(gh release view --json assets --repo github.com/armbian/community | jq '.assets[] | .size, .url, .createdAt' | xargs -n3 -d'\n' | grep -v ".txt" | sed "s/\"//g" | sed -e 's| |\||g')
137
+ C=$(gh release view --json assets --repo github.com/armbian/os | jq '.assets[] | .size, .url, .createdAt' | xargs -n3 -d'\n' | grep -v ".txt" | sed "s/\"//g" | sed -e 's| |\||g')
138
+ D=$(gh release view --json assets --repo github.com/armbian/distribution | jq '.assets[] | .size, .url, .createdAt' | xargs -n3 -d'\n' | grep -v ".txt" | sed "s/\"//g" | sed -e 's| |\||g')
139
+
140
+ # debug
141
+ echo "$A" > a.txt
142
+ echo "$B" > b.txt
143
+ echo "$C" > c.txt
144
+ echo "$D" > d.txt
145
+
146
+ # join all in one file and compress
147
+ for line in $A $B $C $D; do
148
+
149
+ BOARD=$(echo $line | cut -d"|" -f2 | grep -Po 'Armbian.*[0-9][0-9].[0-9].*' | grep -Po '[0-9][0-9].[0-9].*' | cut -d"_" -f2)
150
+ ARMBIAN_VERSION=$(echo $line | cut -d"|" -f2 | grep -Po 'Armbian.*[0-9][0-9].[0-9].*' | grep -Po '[0-9][0-9].[0-9].*' | cut -d"_" -f1)
151
+ IMAGE_SIZE=$(echo $line | cut -d"|" -f1 | sed "s/\.//g" | sed "s/\,//g")
152
+ KERNEL_BRANCH=$(echo $line | cut -d"|" -f2 | grep -Po 'Armbian.*[0-9][0-9].[0-9].*' | grep -Po '[0-9][0-9].[0-9].*' | cut -d"_" -f4)
153
+ IMAGE_RELEASE=$(echo $line | cut -d"|" -f2 | grep -Po 'Armbian.*[0-9][0-9].[0-9].*' | grep -Po '[0-9][0-9].[0-9].*' | cut -d"_" -f3)
154
+ IMAGE_URL=$(echo $line | cut -d"|" -f2)
155
+ # workarounds
156
+ STEP_A=1
157
+ STEP_B=2
158
+ [[ $IMAGE_URL == *i3-wm* || $IMAGE_URL == *kde-* ]] && STEP_A=2 && STEP_B=3
159
+ IMAGE_TARGET=$(echo $IMAGE_URL | cut -d"|" -f2 | grep "minimal\|desktop" | cut -d"|" -f2 | grep -Po 'Armbian.*[0-9][0-9].[0-9].*' | grep -Po '[0-9][0-9].[0-9].*' | cut -d"_" -f4- | grep -Po '_[a-z].*' | cut -d"." -f1 | sed "s/_//" | sed "s/_desktop//" | cut -d"-" -f1,${STEP_A})
160
+ IMAGE_EXTENSION=$(echo $IMAGE_URL | cut -d"|" -f2 | cut -d"|" -f2 | grep -Po 'Armbian.*[0-9][0-9].[0-9].*' | grep -Po '[0-9][0-9].[0-9].*' | sed 's/_sm8250-xiaomi-umi\|_sm8250-xiaomi-elish//g' | sed "s/rc[0-9]//g" | cut -d"_" -f4- | cut -d"-" -f${STEP_B}- | cut -d"_" -f1 | cut -d"." -f1)
161
+ [[ $IMAGE_EXTENSION == $KERNEL_BRANCH || $IMAGE_EXTENSION == ${IMAGE_TARGET} || $IMAGE_EXTENSION =~ boot|csot|boe|sms ]] && unset IMAGE_EXTENSION
162
+ [[ -z ${IMAGE_TARGET} ]] && IMAGE_TARGET="server"
163
+ FILE_EXTENSION=$(echo $IMAGE_URL | cut -d"|" -f2 | cut -d"|" -f2 | grep -Po 'Armbian.*[0-9][0-9].[0-9].*' | grep -Po '[0-9][0-9].[0-9].*' | sed 's/_sm8250-xiaomi-umi\|_sm8250-xiaomi-elish//g' | sed "s/-rc[0-9]//g" | rev | cut -d"_" -f1 | rev | sed 's/.*[^0-9]\([0-9]*\.[0-9]*\.[0-9]*\)//' | sed "s/desktop.\|minimal.//")
164
+ #FILE_EXTENSION=$(echo $IMAGE_URL | grep -o "oowow.*\|img.*")
165
+
166
+ # Clean out application from extension
167
+ FILE_EXTENSION=$(echo $FILE_EXTENSION | sed 's/.*-'$IMAGE_EXTENSION'//g' | sed -e 's/^\.//g')
168
+
169
+ IMAGE_TYPE=$(echo $IMAGE_URL | cut -d"/" -f5)
170
+ IMAGE_CREATED=$(echo $line | cut -d"|" -f3 | sed "s/\//-/g")
171
+ EXPOSED=false
172
+
173
+ # Assemble redirector link
174
+ PREFIX=""
175
+ [[ "${IMAGE_TYPE}" == "os" ]] && PREFIX="nightly/"
176
+ REDI_EXT=$(echo $FILE_EXTENSION | rev | cut -d"." -f1 | rev | sed "s/xz//g")
177
+ REDI_URL="https://dl.armbian.com/${PREFIX}${BOARD,,}/${IMAGE_RELEASE^}_${KERNEL_BRANCH}${IMAGE_TARGET:+_$IMAGE_TARGET}${IMAGE_EXTENSION:+-$IMAGE_EXTENSION}${REDI_EXT:+.$REDI_EXT}"
178
+
179
+ # bypass redirector for weirdos
180
+ if [[ "${FILE_EXTENSION}" =~ boot|csot|boe|sms|rootfs|qcow2 ]]; then REDI_URL=${IMAGE_URL}; fi
181
+
182
+ # check if image is exposed
183
+ while read exposed; do
184
+ [[ $IMAGE_URL =~ $exposed ]] && EXPOSED=true
185
+ done < os/exposed.map
186
+ echo "${BOARD,,}|$ARMBIAN_VERSION|$IMAGE_URL|$REDI_URL|$IMAGE_CREATED|$IMAGE_SIZE|$IMAGE_RELEASE|$KERNEL_BRANCH|$IMAGE_TARGET|$IMAGE_EXTENSION|$EXPOSED|$IMAGE_TYPE|$FILE_EXTENSION"
187
+
188
+ done | sed '1s/^/"board_slug"|"armbian_version"|"file_url"|"redi_url"|"file_updated"|"file_size"|"distro_release"|"kernel_branch"|"image_variant"|"preinstalled_application"|"promoted"|"download_repository"|"file_extension"\n/' | jc --csv | jq '{"assets": .}' > all-images.json
189
+
190
+ - name : " Download and compress torrent files"
191
+ run : |
192
+
193
+ SOURCE=$(mktemp -d)
194
+ DESTINATION=$(mktemp -d)
195
+ rsync -e "ssh -p 10023 -o StrictHostKeyChecking=accept-new" -zqvr --include="*/archive/*.torrent" --exclude="/*/*/*" --exclude="_*/" --exclude="control" --exclude="quotes.txt" --exclude="*/all-torrents.zip" [email protected] :/storage/www/dl/ ${SOURCE}
196
+ find ${SOURCE}/. -mindepth 3 -exec mv -i -- {} ${DESTINATION}/ \;
197
+ zip -qj all-torrents.zip ${DESTINATION}/*.torrent
198
+
199
+ - name : Commit changes if any
200
+ run : |
201
+
202
+ cd armbian.github.io
203
+ git checkout data
204
+ mkdir -p data/
205
+
206
+ cp ${{ github.workspace }}/all-torrents.zip data/
207
+ cp ${{ github.workspace }}/all-images.json data/
208
+ cp ${{ github.workspace }}/exposed.map.autoproposal data/
209
+ cp ${{ github.workspace }}/os/kernel-description.json data/
210
+
211
+ git config --global user.name "github-actions"
212
+ git config --global user.email "[email protected] "
213
+ git add data/.
214
+ git diff --cached --quiet || git commit -m "Update WEB indes files"
215
+ git push
0 commit comments