dev-desktop에서 GitHub로 푸시하기 위한 GitHub App
이 안내는 dev-desktop GitHub App의 서버 측 설정과 디버깅을 위한 것입니다. 사용자는 앱 설치 URL로 안내받기만 하면 되며, 나머지는 모두 문제없이 작동할 것입니다.
모든 GitHub 작업에는 Python GitHub 라이브러리를 사용합니다. 문서는 https://pygithub.readthedocs.io/en/latest/introduction.html 에서 확인할 수 있습니다.
앱 설정 방법
- https://github.com/settings/apps 로 이동하십시오.
- 새 GitHub App(New GitHub App)
- 메타데이터(이름과 URL)를 입력하십시오.
- WebHook 체크박스를 비활성화하십시오.
Contents - Repository contents, commits, branches, downloads, releases, and merges.를 읽기/쓰기(read/write)로 설정하십시오.Workflows - Update GitHub Action workflow files.를 읽기/쓰기(read/write)로 설정하십시오.- “enable on any account“로 설정하십시오.
- 앱 생성(Create App)
- https://github.com/settings/apps/{your_app_name_here} 로 이동하여
App ID를app_id.txt(gen_temp_access_token.py와 같은 폴더)에 복사하십시오.
앱용 .pem 파일을 생성하는 방법
- https://github.com/settings/apps/{your_app_name_here}#private-key 로 이동하여 개인 키를 생성하십시오.
- 다운로드가 시작되면 파일을 비공개 위치에 저장하십시오.
- .pem 파일을
gen_temp_access_token.py와 같은 폴더에 복사하고 이름을dev-desktop.private-key.pem으로 지정하십시오.
사용자에게 앱을 설치하는 방법
- 사용자를 https://github.com/settings/apps/{your_app_name_here}/installations 로 안내하십시오.
- 사용자가 원하는 조직/사용자 계정에 앱을 설치하고, 사용하려는 저장소로 접근 범위를 제한하도록 하십시오.
특정 사용자를 위한 임시 액세스 토큰을 생성하는 방법
gen_temp_access_token.py <github_username> <github_repository_name>를 실행하십시오.
git 명령줄과의 통합
저희는 자격 증명 헬퍼(credential-helpers)를 사용하고 있습니다. 자격 증명 헬퍼를 디버깅하려면 사용자 공간에 두고 다음과 같이 호출하십시오.
git -c credential.helper -c credential.UseHttpPath=true /path/to/helper push origin branch
SSH URL로 등록된 원격 저장소에서는 이 방법이 작동하지 않는다는 점에 유의하십시오. 반드시 HTTPS를 사용해야 합니다!
첫 번째 명령줄 인수는 get, store, remove 중 하나입니다. 이 경우 어차피 호출할 때마다 자격 증명을 다시 생성하므로, get을 제외한 모든 경우에는 그냥 중단(exit(0))합니다.
실제 인자는 stdin을 통해 전달되며 보통 다음과 같은 형태입니다
protocol=https
host=github.com
path=your_repo.git