Open1

Flutter WebのFirebaseへの自動デプロイ

くすたんくすたん
  • 記事にするほどでもないが、公開しておきたいのでスクラップ化
  • 内容が貯まって来たら記事に移す
deploy.yml
on:
  push:
    branches:
      - main
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Setup Flutter
        uses: subosito/flutter-action@v1
        with:
          channel: 'stable'
      - name: setup Node
        uses: actions/setup-node@v1
        with:
          node-version: '12'
      - name: Install
        run: |
          flutter config --enable-web
          flutter pub get
      - name: Build
        run: flutter build web --release --web-renderer html
      - name: setup Firebase
        run: npm install -g firebase-tools
      - name: deploy to Firebase Hosting
        run: firebase deploy --only hosting --token=${{ secrets.FIREBASE_TOKEN }}
      # ビルド成功時にSlack通知を飛ばす
      - name: post message to Slack by success
        if: success()
        uses: tokorom/action-slack-incoming-webhook@master
        env:
          INCOMING_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
        with:
          text: "*HPデプロイ成功です!!* :clap:"
          attachments: |
            [
              {
                "color": "good",
                "author_name": "${{ github.actor }}",
                "author_icon": "${{ github.event.sender.avatar_url }}",
                "fields": [
                  {
                    "title": "実行されたActions",
                    "value": "${{ github.event.repository.url }}/actions/runs/${{ github.run_id }}"
                  },
                  {
                    "title": "サイトURL",
                    "value": "${{ secrets.APP_URL }}"
                  }
                ]
              }
            ]