https://github.com/Financial-Times/github-label-sync#configuration ## 1. 요구사항 - 버전 12 이상의 Node.js가 설치되어 있어야 한다. - 레포에 접근하기 위해 [GitHub access token](https://github.com/settings/tokens)이 필요하다. - labels.json 파일이 필요하다. (아래 labels.json 설정 참고) <br> ## 2. labels.json 설정 새롭게 적용할 label config 인 `labels.json` 을 정의해야 한다. YAML 파일 또한 가능하다. label의 `name`, `color`, `description`, `aliases` 를 정의할 수 있다. [공식 repo 예시](https://github.com/Financial-Times/github-label-sync/blob/master/labels.json) <br> ### 나의 labels.json ```json [ { "name": "API", "color": "0052CC", "description": "type : API 관련 작업" }, { "name": "bug", "color": "d73a4a", "description": "type : 버그 발생" }, { "name": "bugfix", "color": "E99695", "description": "type : 버그 해결" }, { "name": "cleanup", "color": "FEF2C0", "description": "type : 코드를 깔끔하게 정리하는 경우 (리팩토링과 구별)" }, { "name": "doc", "color": "747B8B", "description": "type : 문서 수정" }, { "name": "draft", "color": "0E8A16", "description": "type : draft 상태 PR" }, { "name": "feat", "color": "a2eeef", "description": "type : 구현, 개선 사항" }, { "name": "question", "color": "d876e3", "description": "type : 질문, 질문 해결 시 이슈 닫음" }, { "name": "refactoring", "color": "e4e669", "description": "type : 코드 내부 작동 방식 변경" }, { "name": "setting", "color": "ffffff", "description": "type : 프로젝트 세팅 관련" }, { "name": "test", "color": "008672", "description": "type : 테스트 코드" } ] ``` <br> ## 3. 라이브러리 설치 및 사용법 (Command-Line Interface) ### 설치 **[npm](https://www.npmjs.com/) 을 통해 GitHub Label Sync 설치 :** ```shell npm install -g github-label-sync ``` <br> **`github-label-sync` command-line tool 설명 :** ``` 사용법: github-label-sync [options] <repository> Options: -h, --help 도움말 확인 -V, --version 버전 확인 -a, --access-token <token> GitHub access token -l, --labels <path> label 파일 경로 (Default: labels.json) -d, --dry-run 변경 사항 체크용 옵션. 실제로 Github에 반영되지는 않음. -A, --allow-added-labels repo의 기존 label을 삭제하지 않고 추가, 수정 사항만 적용함. ``` <br> ### 사용법 **repo에서 GitHub Label Sync 실행 (로컬의 `labels.json` 파일 사용) :** ```shell github-label-sync --access-token [액세스토큰] [계정명]/[repo 이름] ``` <br> **실행 예시 :** ```shell github-label-sync --access-token [액세스토큰] [계정명]/[repo 이름] Syncing labels for "[계정명]/[repo 이름]" Validating provided labels Fetching labels from GitHub > Changed: the "bug" label in the repo is out of date. It will be updated to "bug" with color "#d73a4a" and description "type : 버그 띠요옹~ 띠요옹~". > Missing: the "bugfix" label is missing from the repo. It will be created. > Added: the "feat" label in the repo is not expected. It will be deleted. Applying label changes, please wait… Labels updated ``` <br> **다른 경로의 label config 파일을 사용해서 GitHub Label Sync 실행 (JSON 혹은 YAML 파일) :** ```shell github-label-sync --access-token [액세스토큰] --labels my-labels.json [계정명]/[repo 이름] ``` ```shell github-label-sync --access-token [액세스토큰] --labels my-labels.yml [계정명]/[repo 이름] ``` <br> **--dry-run 옵션을 사용하면, GitHub API에 "read" 요청만 한다. 즉, repo에 실제로 반영하기 전에 변경사항을 확인해볼 수 있다.** ```shell github-label-sync --access-token [액세스토큰] --dry-run [계정명]/[repo 이름] ``` <br> **기본적으로 GitHub label sync 실행 시 labels.json에 없는 label은 삭제된다.** **그러나 --allow-added-labels 옵션을 사용하면, 기존 라벨을 삭제하지 않고 새로운 label을 추가하거나 수정된 사항만 적용한다.** ```shell github-label-sync --access-token [액세스토큰] --allow-added-labels [계정명]/[repo 이름] ``` <br> ## 에러 발생 ### 404 not found 에러가 발생하는 경우 1. token 권한을 설정할 때, repo와 **workflow**를 추가 안 한 경우. [GitHub access token](https://github.com/settings/tokens) 에서 권한 변경을 하면 된다. ![[gitgub_access_token_scopes.png]] 참고 : https://github.com/Financial-Times/github-label-sync/issues/48 <br> 2. organization 내의 repo인 경우. 명령어에 계정명 대신 organization 이름 넣으면 된다. ```shell github-label-sync --access-token [액세스토큰] [organization 이름]/[repo 이름] ``` <br> [[어떤 label이 가장 효율적일까]]