Skip to content

Commit

Permalink
Add workflow file for icon review
Browse files Browse the repository at this point in the history
  • Loading branch information
PKief committed Nov 15, 2023
1 parent 783311a commit 4715cc1
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/icon-review.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
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@v4
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 }}_${{ github.sha }}.png
git config user.name "GitHub Actions"
git config user.email "actions@github.com"
git fetch origin
git checkout -b review-images origin/review-images --no-track
git add review-images/
git commit -m "Add generated review image"
git push -u origin review-images
- name: Post review in PR ✍️
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const pngFilePath = './preview.png';
const commentBody = '## Preview \n\nThank you for creating a pull request. This preview shows you how your changes will look on the different themes: \n\n ![Generated Preview](https://raw.githubusercontent.com/' + context.repo.owner + '/' + context.repo.repo + '/' + 'review-images/review-images/${{ github.event.pull_request.number }}_${{ github.sha }}.png) \n\n You can find more information how to contribute in the [contribution guidelines](https://github.com/PKief/vscode-material-icon-theme/blob/main/CONTRIBUTING.md).';
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 }}

0 comments on commit 4715cc1

Please sign in to comment.