-
-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathdata-update-rpi-imager-json.yml
More file actions
82 lines (65 loc) · 2.24 KB
/
data-update-rpi-imager-json.yml
File metadata and controls
82 lines (65 loc) · 2.24 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
name: "Data: Update Raspberry Pi imager JSON"
on:
repository_dispatch:
types: ["Data: Update RPI imager JSON"]
workflow_dispatch: # Manually triggered via GitHub Actions UI
concurrency:
group: rpi-imager-json-update
cancel-in-progress: false
jobs:
Webindex:
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
name: "Generate JSON Index"
runs-on: "ubuntu-24.04"
if: ${{ github.repository_owner == 'Armbian' }}
permissions:
contents: write
timeout-minutes: 180
steps:
- 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: "Install dependencies"
uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: python3-requests xz-utils
version: 1.0
- name: "Build JSON file"
run: |
python3 ${{ github.workspace }}/armbian.github.io/scripts/generate-rpi-imager-json.py \
--output "${{ github.workspace }}/rpi-imager.json"
- 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
git pull --rebase origin data
mkdir -p data
cp "${{ github.workspace }}/rpi-imager.json" data/
git add data/rpi-imager.json
if ! git diff --cached --quiet; then
git commit -m "Update WEB index files"
# 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
git pull --rebase origin data
attempt=$((attempt + 1))
done
echo "Failed to push after $max_attempts attempts" >&2
exit 1
fi