-
Notifications
You must be signed in to change notification settings - Fork 569
72 lines (59 loc) · 2.53 KB
/
validate_and_preview_icons.yml
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
name: Validate and Preview Icons ✅
on:
pull_request:
types: [opened, synchronize]
jobs:
validate_icons:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Set Up Python
uses: actions/setup-python@v4
with:
python-version: "3.9"
- name: Install Dependencies
run: |
pip install cairosvg pillow
- name: Run SVG to PNG and WEBP Conversion
run: python scripts/convert_svg_assets.py
- name: Upload Converted Icons
uses: actions/upload-artifact@v3
with:
name: converted-icons
path: |
png/*.png
webp/*.webp
- name: Post Comment with Preview
uses: marocchino/sticky-pull-request-comment@v2
with:
message: |
## Icon Conversion Results
**Total Icons Processed:** ${{ steps.process.outputs.total_icons }}
**Converted PNGs:** ${{ steps.process.outputs.converted_pngs }}
**Converted WEBPs:** ${{ steps.process.outputs.converted_webps }}
**Removed PNGs:** ${{ steps.process.outputs.removed_pngs }}
**Removed WEBPs:** ${{ steps.process.outputs.removed_webps }}
${{ steps.process.outputs.failed_files }}
### Preview of Converted Icons:
${{ steps.preview.outputs.icon_previews }}
- name: Set Output Variables
id: process
run: |
echo "::set-output name=total_icons::$(grep 'Total icons:' output.log | awk '{print $3}')"
echo "::set-output name=converted_pngs::$(grep 'Converted' output.log | awk '{print $2}')"
echo "::set-output name=converted_webps::$(grep 'Converted' output.log | awk '{print $5}')"
echo "::set-output name=removed_pngs::$(grep 'Removed' output.log | awk '{print $2}')"
echo "::set-output name=removed_webps::$(grep 'Removed' output.log | awk '{print $5}')"
echo "::set-output name=failed_files::$(grep 'The following files failed' -A 10 output.log)"
- name: Generate Icon Previews
id: preview
run: |
ICONS=$(find png/ -type f -name "*.png")
PREVIEWS=""
for ICON in $ICONS; do
ICON_NAME=$(basename $ICON)
PREVIEW="![${ICON_NAME}](https://raw.githubusercontent.com/homarr-labs/dashboard-icons/${{ github.event.pull_request.head.ref }}/png/${ICON_NAME})"
PREVIEWS="$PREVIEWS $PREVIEW"
done
echo "::set-output name=icon_previews::$PREVIEWS"