forked from tabler/tabler-icons
-
Notifications
You must be signed in to change notification settings - Fork 1
129 lines (112 loc) · 3.85 KB
/
validate-pr.yml
File metadata and controls
129 lines (112 loc) · 3.85 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
name: Validate PR
on: [pull_request_target]
permissions:
pull-requests: write
jobs:
validate-pr:
if: github.repository == 'tabler/tabler-icons'
runs-on: ubuntu-latest
permissions:
pull-requests: write
contents: read
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- name: Set base branch and PR info
run: |
BASE_REF="${{ github.event.pull_request.base.ref }}"
BASE_SHA="${{ github.event.pull_request.base.sha }}"
PR_REPO="${{ github.event.pull_request.head.repo.full_name }}"
PR_SHA="${{ github.event.pull_request.head.sha }}"
echo "BASE_REF=${BASE_REF}" >> $GITHUB_ENV
echo "BASE_SHA=${BASE_SHA}" >> $GITHUB_ENV
echo "PR_REPO=${PR_REPO}" >> $GITHUB_ENV
echo "PR_SHA=${PR_SHA}" >> $GITHUB_ENV
# Fetch base branch to ensure it's available
git fetch origin ${BASE_REF}:${BASE_REF} || true
- name: Use Node.js 22
uses: actions/setup-node@v4
with:
node-version: 22
- uses: pnpm/action-setup@v4
name: Install pnpm
with:
version: 10.26.2
- name: Install system dependencies for canvas and rsvg-convert
run: |
sudo apt-get update
sudo apt-get install -y \
build-essential \
libcairo2-dev \
libpango1.0-dev \
libjpeg-dev \
libgif-dev \
librsvg2-dev \
librsvg2-bin
- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install --no-frozen-lockfile
- name: Add in progress comment
id: add-in-progress-comment
uses: thollander/actions-comment-pull-request@v3
with:
comment-tag: validate
mode: upsert
message: |
🔄 Icons are being validated... Please wait...
continue-on-error: true
- name: Validate icons
id: validate
env:
BASE_REF: ${{ env.BASE_REF }}
BASE_SHA: ${{ env.BASE_SHA }}
run: pnpm run --silent validate > ./comment-markup.md
continue-on-error: true
- name: Comment PR
uses: thollander/actions-comment-pull-request@v3
with:
file-path: ./comment-markup.md
comment-tag: validate
mode: recreate
- name: Generate icons comment
id: generate-icons-comment
env:
BASE_REF: ${{ env.BASE_REF }}
BASE_SHA: ${{ env.BASE_SHA }}
PR_REPO: ${{ env.PR_REPO }}
PR_SHA: ${{ env.PR_SHA }}
run: pnpm run --silent generate-icons-comment > ./comment-icons.md || true
continue-on-error: true
- name: Check if icons were added
id: check-icons
run: |
if [ -s ./comment-icons.md ]; then
echo "has_icons=true" >> $GITHUB_OUTPUT
else
echo "has_icons=false" >> $GITHUB_OUTPUT
fi
- name: Comment PR with added icons
if: steps.check-icons.outputs.has_icons == 'true'
uses: thollander/actions-comment-pull-request@v3
with:
file-path: ./comment-icons.md
comment-tag: added-icons
mode: upsert
- name: Remove comment with added icons
if: steps.check-icons.outputs.has_icons == 'false'
uses: thollander/actions-comment-pull-request@v3
with:
comment-tag: added-icons
mode: delete