Skip to content

Commit

Permalink
Update workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
PKief committed Nov 16, 2023
1 parent 783311a commit 4b72516
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/icon-review.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Icon Review

on:
pull_request_target:
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: Get changed files
id: changed-files
uses: jitterbit/get-changed-files@v1

- name: Review SVG files 🔍
run: |
svgFiles=$(echo ${{ steps.changed-files.outputs.modified_files }} | tr ' ' '\n' | grep 'icons/*.svg' | tr '\n' ' ')
npx svg-icon-review ${svgFiles}
- name: Install jq ⚙️
run: sudo apt-get install jq

- name: Upload PNG ⬆️
env:
IMAGE_UPLOAD: ${{ secrets.IMAGE_UPLOAD }}
id: upload
run: |
IMAGE_URL=$(curl --location 'https://freeimage.host/json' --form 'source=@"./preview.png"' --form 'type="file"' --form 'action="upload"' --form 'auth_token="${{env.IMAGE_UPLOAD}}"' | jq -r '.image.url')
echo image_url=$IMAGE_URL >> $GITHUB_ENV
shell: bash

- name: Post review in PR ✍️
uses: actions/github-script@v7
with:
script: |
const image_url = "${{ env.image_url }}";
console.log('URL: '+image_url);
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](' + image_url + ') \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 4b72516

Please sign in to comment.