-
-
Notifications
You must be signed in to change notification settings - Fork 611
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 * Add delete workflow * Update workflow files * Update workflow files
- Loading branch information
Showing
5 changed files
with
139 additions
and
3 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
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
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,61 @@ | ||
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 | ||
Thank you for creating a pull request. This preview shows you how your changes will look on the different themes: | ||
![Generated Preview](https://raw.githubusercontent.com/' + context.repo.owner + '/' + context.repo.repo + '/' + 'review-images/review-images/${{ github.event.pull_request.number }}_${{ github.sha }}.png) | ||
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 }} |
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,59 @@ | ||
name: PR closed | ||
|
||
on: | ||
pull_request: | ||
types: | ||
- closed | ||
|
||
jobs: | ||
cleanup: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout review-images branch ποΈ | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: review-images | ||
|
||
- name: Delete PR related files ποΈ | ||
uses: actions/github-script@v7 | ||
with: | ||
script: | | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const dir = './review-images'; | ||
const prNumber = context.payload.pull_request.number; | ||
fs.readdirSync(dir).forEach(file => { | ||
if (file.startsWith(`${prNumber}_`)) { | ||
fs.unlinkSync(path.join(dir, file)); | ||
} | ||
}); | ||
- name: Commit changes β¬οΈ | ||
run: | | ||
git config --local user.email "action@github.com" | ||
git config --local user.name "GitHub Action" | ||
git add -A | ||
if [[ $(git diff --stat --staged) != '' ]]; then | ||
git commit -m "Delete files related to PR #${{ github.event.pull_request.number }}" | ||
git push | ||
fi | ||
thank_you: | ||
runs-on: ubuntu-latest | ||
if: github.event.pull_request.merged == true | ||
steps: | ||
- name: Post Thank You Comment π | ||
uses: actions/github-script@v7 | ||
with: | ||
script: | | ||
github.rest.issues.createComment({ | ||
issue_number: context.issue.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
body: `## Merge Successful | ||
Thanks for your contribution! π | ||
The changes will be part of the upcoming update on the marketplace.` | ||
}) |
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