デプロイのためのプルリクを作るのが面倒だったのでGitHub CLIを導入した
某サーバレス環境は、GitLabフローを使い、SAM+CodeBuildでビルド、デプロイしています。
feature or bugfix ブランチ -> main は、GitHubのGUIでポチポチいけています。ところが、
main -> it , it -> uat(staging)のようにブランチをーマージさせようとすると、mainブランチにマージさせようとすると力※が働き、非常にプルリクが作りずらい、かつ、オペミスをしそうになります。
そこでmain -> it , it -> uatへのプルリクを簡単に作れるように、GitHub CLIを導入しました。
※おそらく、GitHubフローを使えということでないかと。
GitHub CLIのインストール
wingetコマンドが使える環境の場合
winget install 'GitHub CLI'
モジュールをブラウザでダウンロードしてインストールする場合
https://cli.github.com/ からダウンロードしてインストール
ログイン
下記コマンドを実行して、設定項目を質問されるので選択していく
PS C:\work\step-functions\shinjinji-external-connect-infra> gh auth login
? What account do you want to log into? GitHub.com
? What is your preferred protocol for Git operations? HTTPS
? Authenticate Git with your GitHub credentials? Yes
? How would you like to authenticate GitHub CLI? Login with a web browser
! First copy your one-time code: 5B91-4573
- Press Enter to open github.com in your browser...
✓ Authentication complete. Press Enter to continue...
- gh config set -h github.com git_protocol https
✓ Configured git protocol
✓ Logged in as Hironobu-Utsugi
-
Press Enter to open github.com in your browser... のところで、ブラウザが開くのでCLIに表示されているOne Time Codeを入力する。
-
(GitHub Enterprise + SSO使っていないとおそらくでない)SSO対象のOrganationで認証するための画面。SSOのOrganazation で使いたい場合は、Authorizeを押してからContinueを押す。今回は、SSOのOrganazationにあるリポジトリは使うはないのでそのままCountinueを押した。
-
Authorize githubを押す。
-
GitHubのログインパスワードを入力して、Confirm passwordを押す。
-
完了。(gh auto loginのコマンド実行画面に戻って続きを設定する。)
プルリクの作成
main -> it へのプルリク
gh pr create -H main -B it -t "IT環境へデプロイ" -b " "
-H マージ元のブランチ
-B マージ先のブランチ
-t プルリクのタイトル
-b プルリクの本文
it -> uat(staging) へのプルリク
gh pr create -H it -B uat -t "UAT環境へデプロイ" -b " "
Discussion