-
-
Notifications
You must be signed in to change notification settings - Fork 28
169 lines (138 loc) · 5.83 KB
/
repository-status.yaml
File metadata and controls
169 lines (138 loc) · 5.83 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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
# This workflow fetches the latest Armbian kernel versions from the Armbian APT repository
# and updates SVG badges and JSON data in the 'data' branch.
#
# Requirements:
# - A 'data' branch must exist in the repository (will be created if missing)
# - Templates: armbian-badge-current.svg and armbian-badge-edge.svg must exist in templates/
#
# Outputs:
# - data/current.svg: Badge for CURRENT kernel version
# - data/edge.svg: Badge for EDGE kernel version
# - data/kernel-versions.json: JSON with CURRENT and EDGE version strings
name: "Data: Fetch Armbian kernel versions"
on:
schedule:
# Run at 2:15 AM daily (UTC)
- cron: '15 2 * * *'
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}
cancel-in-progress: false
jobs:
jira:
runs-on: ubuntu-24.04
name: "Get from Armbian Repository"
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0
path: armbian.github.io
- name: Get info from Armbian repository
run: |
set -euo pipefail
KEYRING="/usr/share/keyrings/armbian.gpg"
LIST="/etc/apt/sources.list.d/armbian.list"
# Retry function for network operations
retry() {
local max_attempts=3
local attempt=1
local delay=5
while [ $attempt -le $max_attempts ]; do
if "$@"; then
return 0
fi
echo "Attempt $attempt failed, retrying in ${delay}s..." >&2
sleep $delay
attempt=$((attempt + 1))
delay=$((delay * 2))
done
echo "All $max_attempts attempts failed" >&2
return 1
}
# Import Armbian APT key
retry curl -fsSL https://apt.armbian.com/armbian.key | sudo gpg --dearmor -o "$KEYRING"
sudo chmod go+r "$KEYRING"
# Detect release codename (Ubuntu/Debian)
. /etc/os-release
RELEASE="${UBUNTU_CODENAME:-${VERSION_CODENAME}}"
# Add Armbian repo
ARCH="$(dpkg --print-architecture)"
echo "deb [arch=$ARCH signed-by=$KEYRING] https://beta.armbian.com $RELEASE main ${RELEASE}-utils ${RELEASE}-desktop" \
| sudo tee "$LIST" > /dev/null
retry sudo apt-get update -qq
# Extract kernel versions with improved validation
CURRENT=$(apt search --names-only 'linux-image-current-x86' 2> /dev/null | grep Armbian | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1)
EDGE=$(apt search --names-only 'linux-image-edge-x86' 2> /dev/null | grep Armbian | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1)
# Validate versions
if [[ -z "${CURRENT}" || -z "${EDGE}" ]]; then
echo "Failed to determine CURRENT/EDGE versions" >&2
echo "CURRENT: '${CURRENT:-MISSING}', EDGE: '${EDGE:-MISSING}'" >&2
exit 1
fi
# Verify versions match semver pattern
if ! [[ "${CURRENT}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || ! [[ "${EDGE}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Invalid version format detected" >&2
exit 1
fi
echo "Detected versions - CURRENT: ${CURRENT}, EDGE: ${EDGE}"
# Generate badges
sed "s/{{VERSION}}/$CURRENT/g" armbian.github.io/templates/armbian-badge-current.svg > current.svg
sed "s/{{VERSION}}/$EDGE/g" armbian.github.io/templates/armbian-badge-edge.svg > edge.svg
# Write JSON for other usage
printf '{\n "CURRENT": "%s",\n "EDGE": "%s"\n}\n' "${CURRENT}" "${EDGE}" > kernel-versions.json
- name: Commit changes if any
run: |
set -euo pipefail
cd armbian.github.io
# Fetch the data branch with proper error handling
if ! git fetch origin data; then
echo "Error: Failed to fetch 'data' branch from origin" >&2
echo "Please ensure the 'data' branch exists in the repository" >&2
exit 1
fi
# Checkout or create the data branch
if git rev-parse --verify origin/data >/dev/null 2>&1; then
git checkout data
else
echo "Creating new 'data' branch from origin/main" >&2
git checkout --orphan data
git rm -rf . || true
fi
git pull --rebase origin data
# Ensure data directory exists
mkdir -p data
# Move generated files to data directory
mv "${{ github.workspace }}/current.svg" data/
mv "${{ github.workspace }}/edge.svg" data/
mv "${{ github.workspace }}/kernel-versions.json" data/
# Configure git
git config user.name "github-actions"
git config user.email "github-actions@github.com"
# Commit and push changes
git add data/current.svg data/edge.svg data/kernel-versions.json
if ! git diff --cached --quiet; then
git commit -m "Update repository data"
# 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.GITHUB_TOKEN }}
event-type: "Web: Directory listing"