-
-
Notifications
You must be signed in to change notification settings - Fork 640
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add workflow file * Update workflow file
- Loading branch information
Showing
1 changed file
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
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$') | ||
npx svg-icon-review ${svgFiles} | ||
- name: Post previews in PR | ||
uses: actions/github-script@v5 | ||
with: | ||
script: | | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const github = require('@actions/github'); | ||
const core = require('@actions/core'); | ||
const context = github.context; | ||
const token = core.getInput('github-token', {required: true}); | ||
const octokit = github.getOctokit(token); | ||
const png_files = fs.readdirSync('.').filter(fn => fn.endsWith('.png')); | ||
for (const png_file of png_files) { | ||
const content = fs.readFileSync(png_file, 'base64'); | ||
const comment = `!${png_file}`; | ||
octokit.rest.issues.createComment({ | ||
...context.repo, | ||
issue_number: context.issue.number, | ||
body: comment | ||
}); | ||
} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |