LoginSignup
12
10

More than 3 years have passed since last update.

【Github Actions】FlutterのビルドをApp Distributionに自動デプロイする

Last updated at Posted at 2019-11-29

はじめに

Pull Requestがマージされた際に、最新のマージされたバージョンをFirebase App Distributionにデプロイする作業をGithub Actionsで自動化したものです。 Github Actionsの基本的な動かし方についてはこちらの記事でわかりやすく説明されているので参考にしてみてください。

Workflow全体

.github/workflows/deploy_after_merge.yml
name: deploy_after_merge

on:
  push:
    branches:
    - master

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v1
      - name: set up JDK 1.8
        uses: actions/setup-java@v1
        with:
          java-version: 1.8
      - uses: subosito/flutter-action@v1
        with:
          channel: 'stable'
      - name: build and download apk
        run: flutter build apk --release
      - name: upload artifact to Firebase App Distribution
        uses: wzieba/Firebase-Distribution-Github-Action@v1.1.1
        with:
          appId: ${{secrets.FIREBASE_APP_ID}}
          token: ${{secrets.FIREBASE_TOKEN}}
          groups: ANDROID_TEST
          file: build/app/outputs/apk/release/app-release.apk

使用するオープンソースのActions

flutterのコマンドを打つための Action です。
subosito/flutter-action - GitHub
App Distribution にデプロイするための Action です。
wzieba/Firebase-Distribution-Github-Action - GitHub

secretsの設定

.github/workflows/deploy_after_merge.yml
with:
  appId: ${{secrets.FIREBASE_APP_ID}}
  token: ${{secrets.FIREBASE_TOKEN}}
  groups: DEPLOY_TEST
  file: build/app/outputs/apk/release/app-release.apk

FIREBASE_APP_IDと、FIREBASE_TOKENという名前の Secret を Github 上に作る必要があります。Secret の作り方はGithubのヘルプを参考にしてみてください。

  • FIREBASE_APP_IDの設定
    スクリーンショット 2019-11-28 20.28.50.png
    Firebase console で「プロジェクトの設定」という画面を開くとアプリIDがあります。FIREBASE_APP_IDという名前で、ちょうど上の画像で赤線で隠されている値をGithubのSecretsに追加します。

  • FIREBASE_TOKENの設定
    Firebaseのリファレンスを参考にトークンを取得した後、FIREBASE_TOKENという名前でSecretsに追加します。

参考

12
10
3

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
12
10