-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Expand file tree
/
Copy pathmaintenance-check-board-assets.yml
More file actions
172 lines (145 loc) · 6.14 KB
/
Copy pathmaintenance-check-board-assets.yml
File metadata and controls
172 lines (145 loc) · 6.14 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
170
171
172
name: "Maintenance: Check board assets"
on:
pull_request_target:
paths:
- "config/boards/**"
env:
WEBSITE_REPO: "armbian/armbian.github.io"
WEBSITE_REF: "main"
BOARDS_PATH: "config/boards"
BOARD_IMAGES_DIR: "board-images"
VENDOR_LOGOS_DIR: "board-vendor-logos"
permissions:
contents: read
jobs:
Check:
name: "Verify assets for newly added boards"
runs-on: ubuntu-24.04
permissions:
contents: read
pull-requests: write
issues: write
steps:
- name: "Checkout build repo (PR head)"
uses: actions/checkout@v6
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
- name: "Checkout armbian.github.io (images repo)"
uses: actions/checkout@v6
with:
repository: ${{ env.WEBSITE_REPO }}
ref: ${{ env.WEBSITE_REF }}
path: website
fetch-depth: 1
- name: "Find newly added board configs in PR"
id: added
shell: bash
run: |
set -euo pipefail
BASE_SHA="${{ github.event.pull_request.base.sha }}"
HEAD_SHA="${{ github.event.pull_request.head.sha }}"
git diff --name-status "${BASE_SHA}" "${HEAD_SHA}" -- "${BOARDS_PATH}" \
| awk '$1=="A"{print $2}' \
| grep -E '\.(conf|csc|wip|tvb)$' \
> added-files.txt || true
echo "New board config files:"
cat added-files.txt || true
if [[ ! -s added-files.txt ]]; then
echo "No new board configs detected."
echo "none=true" >> "$GITHUB_OUTPUT"
else
echo "none=false" >> "$GITHUB_OUTPUT"
fi
- name: "Validate board image + vendor logo exist on website repo"
id: validate
if: ${{ steps.added.outputs.none != 'true' }}
shell: bash
run: |
set -euo pipefail
missing_any=0
comment_file="$(mktemp)"
{
echo "This PR adds new board configuration(s). Required assets must already exist in [github/${WEBSITE_REPO}](https://github.com/${WEBSITE_REPO})."
echo "They are required by [Armbian Imager](https://github.com/armbian/imager) to ensure all boards are displayed with proper images."
echo ""
echo "- Board images: \`${BOARD_IMAGES_DIR}/<board>.png\` (1920x1080 px transparent)"
echo "- Vendor logos: \`${VENDOR_LOGOS_DIR}/<vendor>-logo.png\` (512x512 px transparent)"
echo ""
echo "### Missing items"
echo ""
} > "$comment_file"
while IFS= read -r cfg; do
[[ -z "${cfg}" ]] && continue
file="$(basename "$cfg")"
board="${file%.*}"
vendor="$(
grep -E '^[[:space:]]*(export[[:space:]]+|declare[[:space:]]+-g[[:space:]]+)?BOARD_VENDOR[[:space:]]*=' -m1 -- "$cfg" 2>/dev/null \
| sed -E 's/^[[:space:]]*(export[[:space:]]+|declare[[:space:]]+-g[[:space:]]+)?BOARD_VENDOR[[:space:]]*=[[:space:]]*//; s/^"//; s/"$//' \
| tr '[:upper:]' '[:lower:]' \
| tr '_' '-' \
| awk 'NF{print; exit}' \
|| true
)"
board_img_match="$(find "website/${BOARD_IMAGES_DIR}" -maxdepth 1 -type f -iname "${board}.png" | head -n1 || true)"
if [[ -z "${board_img_match}" ]]; then
{
echo "- ❌ **Board image missing** for \`${board}\`"
echo " - Expected: \`${BOARD_IMAGES_DIR}/${board}.png\`"
echo " - Fix: add the file to **${WEBSITE_REPO}** (folder \`${BOARD_IMAGES_DIR}/\`)"
echo ""
} >> "$comment_file"
missing_any=1
fi
if [[ -z "${vendor}" ]]; then
{
echo "- ❌ **BOARD_VENDOR not found** in \`${cfg}\`"
echo " - Fix: add e.g. \`BOARD_VENDOR=\"radxa\"\` (lowercase recommended)"
echo ""
} >> "$comment_file"
missing_any=1
continue
fi
found_logo="$(find "website/${VENDOR_LOGOS_DIR}" -maxdepth 1 -type f \
\( -iname "${vendor}-logo.png" -o -iname "${vendor}-logo.jpg" -o -iname "${vendor}-logo.jpeg" -o -iname "${vendor}-logo.svg" \) \
| head -n1 || true)"
if [[ -z "${found_logo}" ]]; then
{
echo "- ❌ **Vendor logo missing** for vendor \`${vendor}\` (used by board \`${board}\`)"
echo " - Expected: \`${VENDOR_LOGOS_DIR}/${vendor}-logo.png\`"
echo " - Fix: add the file to **${WEBSITE_REPO}** (folder \`${VENDOR_LOGOS_DIR}/\`)"
echo " - Naming rules: lowercase, dashes (e.g. \`kobol-logo.png\`, not \`Kobol_logo.png\`)"
echo ""
} >> "$comment_file"
missing_any=1
fi
done < added-files.txt
if [[ "${missing_any}" -ne 0 ]]; then
echo "missing=true" >> "$GITHUB_OUTPUT"
echo 'comment<<EOF' >> "$GITHUB_OUTPUT"
cat "$comment_file" >> "$GITHUB_OUTPUT"
echo 'EOF' >> "$GITHUB_OUTPUT"
echo "::warning ::Missing required assets (see PR comment)."
else
echo "missing=false" >> "$GITHUB_OUTPUT"
fi
- name: "Comment on PR with missing asset instructions"
if: always() && github.event_name == 'pull_request_target' && steps.validate.outputs.missing == 'true'
uses: actions/github-script@v8
env:
COMMENT_BODY: ${{ steps.validate.outputs.comment }}
WEBSITE_REPO: ${{ env.WEBSITE_REPO }}
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const body =
`### 🚫 Missing required board assets
${process.env.COMMENT_BODY}
Once the missing files are added (or a PR is opened in **${process.env.WEBSITE_REPO}**), re-run this check.
`;
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body
});