Firebase へのデプロイ

Test, build, and deploy your applications deploy your code to Firebase using the firebase-deploy pipe in your Bitbucket Pipelines configuration.

A full end-to-end example is available in this repository if you prefer hands-on experimentation with deploying to Firebase using Pipelines and Pipes

ステップ 1: Firebase トークンとプロジェクト名を変数として追加する

Define the following two variables in your settings:

名前

FIREBASE_TOKEN

Firebase CLI token. Use a secured variable for this so that it is masked and encrypted in your logs.

FIREBASE_PROJECT

Firebase のプロジェクト名。プロジェクトを持っていない場合、Firebase コンソールに移動して作成する必要があります。

これらの変数は、デプロイ環境、リポジトリ、またはワークスペース レベルで定義できます。

ステップ 2: Firebase 環境をセットアップする

The next steps presume you have installed the Firebase CLI.

プロジェクトには、Firebase 構成を含む firebase.json ファイルを含める必要があります。

このファイルは、ローカルで以下を実行した後に自動的に生成されます。

firebase init

Here’s the firebase.json file from our example repository:

firebase.json

{ "hosting": { "headers": [ {"source": "/service-worker.js", "headers": [{"key": "Cache-Control", "value": "no-cache"}]} ], "public": "build", "ignore": [ "firebase.json", "**/.*", "**/node_modules/**" ], "rewrites": [ { "source": "**", "destination": "/index.html" } ] } }

ステップ 3: パイプを使用して Firebase にデプロイする

Then we add the deployment configuration in your bitbucket-pipelines.yml file. We've included the deployment: keyword so that Bitbucket Deployments can track your deployment.

Below is a sample Bitbucket Pipelines configuration that deploys a ReactJS application (created with create-react-app), to Firebase. This example also provides insights on some best practices, like having separate steps for building and deploying, and using Bitbucket Deployments to review the deployment.

bitbucket-pipelines.yml

image: node pipelines: default: - step: name: Test script: - npm install && npm test - step: name: Build script: - npm install && npm run build artifacts: - build/** - step: name: Deploy to Firebase deployment: production script: - pipe: atlassian/firebase-deploy:5.1.1 variables: KEY_FILE: $KEY_FILE

これで、コードをコミットすると、進捗に応じ、テスト、ビルド、およびデプロイのステップを確認できます。成功が報告されると、Firebase 内でアプリケーションが起動して実行されます。

 

さらにヘルプが必要ですか?

アトラシアン コミュニティをご利用ください。