LoginSignup
1
0

More than 1 year has passed since last update.

FirebaseにアプリデプロイでFastlaneのfirebase_app_distributionを使ったときのエラーの躓きについて

Last updated at Posted at 2023-04-24

#はじめに
久しぶりにやると記憶が飛んで毎回つまづくのでメモ。
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に行きプロジェクト概要の歯車からプロジェクト設定へ移動する
スクリーンショット 2023-04-24 22.30.42.png

サービスアカウントへ

タブのサービスアカウントに行く

スクリーンショット 2023-04-24 22.30.51.png

Google Cloudの設定へ

スクリーンショット 2023-04-24 22.31.13.png

ロール権限

対象のアカウントに「Firebase App Distribution Admin SDK サービスエージェント」を付与
スクリーンショット 2023-04-24 22.32.06.png

鍵の管理へ

対象のアカウントから鍵の管理に移動
スクリーンショット 2023-04-24 23.40.26.png

鍵の作成

新しい鍵を作成からjsonを指定して作成

スクリーンショット 2023-04-24 23.40.40.png

スクリーンショット 2023-04-24 23.41.47.png

jsonファイルをbase64へ

cat key.json | base64

base64のコードをgithubActionで利用。

参考

https://qiita.com/tsuruken/items/83a546319defe86bad56
https://qiita.com/aitaro/items/abdc8a88badaba6b3a94

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0