-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enhance
bezier-figma-plugin
by using github action (#1596)
<!-- How to write a good PR title: - Follow [the Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/). - Give as much context as necessary and as little as possible - Prefix it with [WIP] while it’s a work in progress --> ## Self Checklist - [x] I wrote a PR title in **English**. - [x] I added an appropriate **label** to the PR. - [x] I wrote a commit message in **English**. - [x] I wrote a commit message according to [**the Conventional Commits specification**](https://www.conventionalcommits.org/en/v1.0.0/). - [x] [I added the appropriate **changeset**](https://github.com/channel-io/bezier-react/blob/main/CONTRIBUTING.md#add-a-changeset) for the changes. - [ ] ~~[Component] I wrote **a unit test** about the implementation.~~ - [ ] ~~[Component] I wrote **a storybook document** about the implementation.~~ - [ ] ~~[Component] I tested the implementation in **various browsers**.~~ - Windows: Chrome, Edge, (Optional) Firefox - macOS: Chrome, Edge, Safari, (Optional) Firefox - [ ] ~~[*New* Component] I added my username to the correct directory in the `CODEOWNERS` file.~~ ## Related Issue - #863 - changeset 자동생성과 description 생성 기능까지 추가하면 resolve 해도 될 것 같습니다. ## Summary <!-- Please add a summary of the modification. --> - `bezier-figma-pluain`의 실행 속도와 구조를 개선합니다. - 아이콘 마다 git blob 을 만드는 과정을 없애고 깃헙 액션에서 아이콘을 생성하도록 합니다. ## Demo **개인 레포지토리 타겟으로 동작 시연 영상** https://github.com/channel-io/bezier-react/assets/28595102/67927889-6a82-463a-aa00-d266c6b38240 **[깃헙 액션 다 돌고난 후](https://github.com/yangwooseong/bezier-react/pull/39/files)** ## Details <!-- Please add a detailed description of the modification. (such as AS-IS/TO-DO)--> - 기존의 플러그인 동작방식은, 플러그인 피그마 API 를 통해 선택한 아이콘들을 모두 svg 로 변환하여 이걸 git blob 으로 변환한 후 github REST API 를 통해 pr 을 만드는 과정을 거쳤습니다. 그런데 500개가 넘는 아이콘에 대하여 `/git/blobs` API를 모두 호출해야 해서 시간이 많이 소요되었습니다. (대략 9분정도 소요) - 이번 pr 로 동작방식이 다음과 같이 변경되었습니다. 1. `Node.exportAsync` 메서드를 통해 선택한 아이콘들을 svg string으로 변환 2. 아이콘 이름과 svg string을 키 밸류로 하는 json 객체(`icons.json`)생성 3. github API 를 통해 `icons.json`만 변경사항으로 가지는 pr 생성 4. pr 이 생성되면 github action 이 트리거 되어 `icons.json` 파일로부터 각 아이콘 이름을 파일 이름으로, svg string 을 파일 내용으로 하여 아이콘 파일을 생성하는 스크립트(`generate-icon-files.js`) 실행 5. `icons.json` 삭제하는 커밋 생성 - 이 과정이 다 도는데 10초 정도가 걸리게 됩니다. 또한, `icons.json`을 보고 추가로 github action 을 트리거할 수 있기 때문에, changeset 생성이나 적절한 description 생성같은 기능도 추후에 덧붙이기 용이한 구조로 변경되었습니다. - 기존의 플러그인이 생성한 icon 파일과 변경사항이 없기를 원했지만, `devices.svg` 파일 한개에 대해서는 diff 가 발생하는 것을 막지 못했습니다([#](https://github.com/yangwooseong/bezier-react/pull/39/files#diff-e7d3a3a633d92885f712dc52585180368d0d7bcc0d02da7e4b0de47e108040fd)). 아마 figmaAPI를 호출해서 svg 로 변환하는 것과 이번에 사용한 `Node.exportAsync` 의 결과물이 완전히 일치하지 않아서 그런 것 같습니다. 겉으로 보이는 것은 완전히 동일해서 diff 가 생겨도 무방하지 않을까 생각합니다만, 새로운 플러그인이 배포되면 한번 조정하는 작업이 필요해 보입니다. ## Breaking change or not (Yes/No) <!-- If Yes, please describe the impact and migration path for users --> No ## References <!-- External documents based on workarounds or reviewers should refer to --> - 주로 https://junghyeonsu.com/posts/quickly-apply-icons-that-exist-in-figma-to-your-dev-team/ 이 블로그를 참고하였습니다. - https://www.figma.com/plugin-docs/how-plugins-run/ - https://docs.github.com/en/rest/git?apiVersion=2022-11-28
- Loading branch information
1 parent
772d763
commit 9d44070
Showing
11 changed files
with
213 additions
and
212 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,7 @@ | ||
--- | ||
"bezier-figma-plugin": minor | ||
--- | ||
|
||
Enhance bezier-figma-plugin running performance | ||
- Remove svg extract process using FigmaAPI and merely send json file that contains svg string | ||
- Make icon files based on given json file during Github Action |
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,5 @@ | ||
--- | ||
"@channel.io/bezier-icons": minor | ||
--- | ||
|
||
Add script for generating svg file from icons.json |
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,38 @@ | ||
name: Generate icon files from icons.json file | ||
|
||
on: | ||
push: | ||
branches: | ||
- icon-update-* | ||
paths: | ||
- packages/bezier-icons/icons.json | ||
|
||
jobs: | ||
generate-svg: | ||
name: Generate icon files from icons.json file | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Repo | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18.17.1 | ||
|
||
- name: Git Config | ||
run: | | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "ch-builder" | ||
- name: Generate Svg files from icons.json | ||
run: | | ||
node packages/bezier-icons/scripts/generate-icon-files.js | ||
git add . | ||
git commit -m "feat(bezier-icons): generate icon files from icons.json" | ||
- name: Delete icons.json files | ||
run: | | ||
git rm packages/bezier-icons/icons.json | ||
git commit -m "feat(bezier-icons): remove icons.json" | ||
git push |
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
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
Oops, something went wrong.