-
-
Notifications
You must be signed in to change notification settings - Fork 27
151 lines (124 loc) · 4.51 KB
/
data-update-download-index.yml
File metadata and controls
151 lines (124 loc) · 4.51 KB
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
name: "Data: Generate Armbian download index"
on:
repository_dispatch:
types: ["Data: Update download index"]
workflow_dispatch:
permissions:
contents: write
concurrency:
group: ${{ github.workflow }}
cancel-in-progress: false
env:
SOURCE_OF_TRUTH: "rsync://fi.mirror.armbian.de"
jobs:
Webindex:
name: "Generate JSON Index"
runs-on: ubuntu-24.04
if: ${{ github.repository_owner == 'Armbian' }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout build framework repository
uses: actions/checkout@v6
with:
repository: armbian/build
fetch-depth: 1
clean: false
path: build
- name: Checkout OS repository
uses: actions/checkout@v6
with:
repository: armbian/os
fetch-depth: 1
clean: false
path: os
- name: Checkout armbian.github.io repository
uses: actions/checkout@v6
with:
repository: armbian/armbian.github.io
fetch-depth: 0
clean: false
path: armbian.github.io
- name: Checkout this repo (script)
uses: actions/checkout@v6
with:
fetch-depth: 1
clean: false
path: runner
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y jq jc rsync curl
- name: Get exposed.map
run: |
curl -fsSL -o "${GITHUB_WORKSPACE}/exposed.map" https://github.armbian.com/release-targets/exposed.map
- name: Generate armbian-images.json (with Bigin company enrichment)
working-directory: runner
env:
# Zoho OAuth credentials for Bigin enrichment
ZOHO_CLIENT_ID: ${{ secrets.ZOHO_CLIENT_ID }}
ZOHO_CLIENT_SECRET: ${{ secrets.ZOHO_CLIENT_SECRET }}
ZOHO_REFRESH_TOKEN: ${{ secrets.ZOHO_REFRESH_TOKEN }}
# You can also disable enrichment if needed:
# BIGIN_ENABLE: "false"Infrastructure: Update redirector
run: |
set -euo pipefail
OUT="armbian-images.json" \
OS_DIR="${GITHUB_WORKSPACE}" \
BOARD_DIR="${GITHUB_WORKSPACE}/build/config/boards" \
SOURCE_OF_TRUTH="${SOURCE_OF_TRUTH}" \
./scripts/generate-armbian-images-json.sh
# Copy into workspace root so later steps can reference easily
cp armbian-images.json "${GITHUB_WORKSPACE}/armbian-images.json"
- name: Download and compress torrent files
run: |
set -euo pipefail
SOURCE=$(mktemp -d)
DESTINATION=$(mktemp -d)
rsync -zqvr \
--include="*/archive/*.torrent" \
--exclude="/*/*/*" \
--exclude="_*/" \
--exclude="control" \
--exclude="quotes.txt" \
--exclude="*/all-torrents.zip" \
"${SOURCE_OF_TRUTH}/dl/" "${SOURCE}"
find ${SOURCE}/. -mindepth 3 -exec mv -i -- {} ${DESTINATION}/ \;
zip -qj "${GITHUB_WORKSPACE}/all-torrents.zip" ${DESTINATION}/*.torrent
- name: Commit changes if any
run: |
set -euo pipefail
cd armbian.github.io
git config user.name "github-actions"
git config user.email "github-actions@github.com"
git fetch origin data
git checkout data
mkdir -p data
cp "${GITHUB_WORKSPACE}/armbian-images.json" data/
cp "${GITHUB_WORKSPACE}/all-torrents.zip" data/
git add data/armbian-images.json data/all-torrents.zip
if ! git diff --cached --quiet; then
git commit -m "Update armbian-images.json and all-torrents.zip"
# Push with retry logic
max_attempts=3
attempt=1
while [ $attempt -le $max_attempts ]; do
if git push origin data; then
echo "Successfully pushed to data branch"
exit 0
fi
# Pull with rebase to resolve conflicts
echo "Push failed, attempting to pull and rebase..." >&2
if ! git pull --rebase origin data; then
echo "Pull/rebase failed, will retry push..." >&2
fi
attempt=$((attempt + 1))
done
echo "Failed to push after $max_attempts attempts" >&2
exit 1
fi
- name: "Generate directory"
uses: peter-evans/repository-dispatch@v4
with:
token: ${{ secrets.DISPATCH }}
event-type: "Infrastructure: Update redirector"