-
-
Notifications
You must be signed in to change notification settings - Fork 641
54 lines (48 loc) · 1.76 KB
/
icon-review.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
name: Icon Review
on:
pull_request:
paths:
- 'icons/*.svg'
jobs:
icon-review:
name: Icon Review
runs-on: ubuntu-latest
env:
TARGET_BRANCH: ${{ github.event.pull_request.base.ref }}
steps:
- name: Checkout 🛎️
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Review SVG files 🔍
run: |
svgFiles=$(git diff origin/${{ env.TARGET_BRANCH }} --diff-filter=ACMRTUX --name-only | grep '.svg$')
echo "SVG files changed: ${svgFiles}"
npx svg-icon-review ${svgFiles}
- name: Upload PNG to Repository
run: |
mkdir -p review-images
mv ./preview.png review-images/${{ github.event.pull_request.number }}.png
git config user.name "GitHub Actions"
git config user.email "[email protected]"
git checkout -b review-images
git config pull.rebase true
git pull origin review-images
git add review-images/
git commit -m "Add generated review image"
git push origin review-images
- name: Post previews in PR
uses: actions/github-script@v6
with:
script: |
const fs = require('fs');
const pngFilePath = './preview.png';
const commentBody = '![Generated PNG](https://raw.githubusercontent.com/' + context.repo.owner + '/' + context.repo.repo + '/' + 'review-images/review-images/${{ github.event.pull_request.number }}.png)';
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: commentBody
})
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}