#はじめに
久しぶりにやると記憶が飛んで毎回つまづくのでメモ。
Fastlaneからfirebase_app_distributionで
firebase_app_distribution(
app: "[appid]",
groups_file: "hogehoge.txt",
release_notes: "hogehoge"
)
でアプリを配信したくGithubActionでFastlaneを叩くと下記のエラー
GOOGLE_APPLICATION_CREDENTIALS周りは「Authenticated successfully.」で
問題なさそう。
[10:32:12]: Authenticating with GOOGLE_APPLICATION_CREDENTIALS environment variable: /home/runner/work/***-android/***-android/...
Authenticated successfully.
[10:32:19]: the server responded with status 403
+------+----------------------------+-------------+
| fastlane summary |
+------+----------------------------+-------------+
| Step | Action | Time (in s) |
+------+----------------------------+-------------+
| 1 | default_platform | 0 |
| 2 | app:assembleProductRelease | 305 |
| 3 | git_branch | 0 |
| 4 | last_git_commit | 0 |
| 💥 | firebase_app_distribution | 0 |
| 6 | slack | 0 |
+------+----------------------------+-------------+
Please update using `bundle update fastlane`
304
bundler: failed to load command: fastlane (/opt/hostedtoolcache/Ruby/2.6.10/x64/bin/fastlane)
305
/opt/hostedtoolcache/Ruby/2.6.10/x64/lib/ruby/gems/2.6.0/gems/faraday-1.2.0/lib/faraday/response/raise_error.rb:20:in `on_complete': [!] the server responded with status 403
原因
Firebaseのサービスアカウントのロール権限に「Firebase App Distribution Admin SDK サービス エージェント」がついていなかったことが原因だった。
このほかにもキー設定などもしていないと同様のエラーが出ると思う。
改善
基本はドキュメントの通りにすればうまく行く
https://firebase.google.com/docs/app-distribution/ios/distribute-fastlane
Firebaseのappdistributionへ
Firebaseのコンソールより対象のアプリのApp Distribusionに行きプロジェクト概要の歯車からプロジェクト設定へ移動する
サービスアカウントへ
タブのサービスアカウントに行く
Google Cloudの設定へ
ロール権限
対象のアカウントに「Firebase App Distribution Admin SDK サービスエージェント」を付与
鍵の管理へ
鍵の作成
新しい鍵を作成からjsonを指定して作成
jsonファイルをbase64へ
cat key.json | base64
base64のコードをgithubActionで利用。
参考
https://qiita.com/tsuruken/items/83a546319defe86bad56
https://qiita.com/aitaro/items/abdc8a88badaba6b3a94